Skip to content

Commit ab4e053

Browse files
committed
automatic generation of tests
1 parent cd0f6ae commit ab4e053

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+587
-93
lines changed

Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "hikoru-ucdb"
2+
name = "ucdb"
33
version = "0.1.0"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
@@ -10,6 +10,7 @@ url = "https://www.unicode.org/Public"
1010

1111
[dependencies]
1212

13+
1314
[build-dependencies]
1415
reqwest = { version = "0.12", features = ["blocking"] }
1516
cargo_metadata = { version = "0.19" }

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
# Hikoru Unicode Database
1+
# Unicode Database (UCDB)
2+
This is part of the HikoGUI project.
23

3-
This crate contains the Unicode database build into the executable.
4-
The Unicode database is compressed and has O(1) two-step associative lookups.
4+
This crate contains the Unicode Database (UCDB) which will be build directly
5+
into your application. It is a fast and memory efficient. It can be used for
6+
various purposes such as normalization, text segmentation, script detection,
7+
bidirectional language support, etc.
58

9+
Most of the database is used for looking attributes of a code-point, it does
10+
this using a O(1) two-step associative lookup. The composition/decomposition
11+
tables are a bit more complex.
612

713
## License
814

build_src/generators.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,18 @@ pub fn generate_enum_table(
206206
write!(fd, " }};\n")?;
207207
write!(fd, "}}\n\n")?;
208208

209+
write!(fd, "#[cfg(all(test, not(debug_assertions)))]\n")?;
210+
write!(fd, "#[test]\n")?;
211+
write!(fd, "fn {}_full_coverage()\n", name)?;
212+
write!(fd, "{{\n")?;
213+
write!(fd, " for c in '\\u{{0000}}'..='\\u{{d7ff}}' {{\n")?;
214+
write!(fd, " let _ = get_{}(c);\n", name)?;
215+
write!(fd, " }}\n")?;
216+
write!(fd, " for c in '\\u{{e000}}'..='\\u{{10ffff}}' {{\n")?;
217+
write!(fd, " let _ = get_{}(c);\n", name)?;
218+
write!(fd, " }}\n")?;
219+
write!(fd, "}}\n\n")?;
220+
209221
return Ok(());
210222
}
211223

@@ -383,5 +395,17 @@ pub fn generate_bool_table(
383395
write!(fd, " }};\n")?;
384396
write!(fd, "}}\n\n")?;
385397

398+
write!(fd, "#[cfg(all(test, not(debug_assertions)))]\n")?;
399+
write!(fd, "#[test]\n")?;
400+
write!(fd, "fn {}_full_coverage()\n", name)?;
401+
write!(fd, "{{\n")?;
402+
write!(fd, " for c in '\\u{{0000}}'..='\\u{{d7ff}}' {{\n")?;
403+
write!(fd, " let _ = get_{}(c);\n", name)?;
404+
write!(fd, " }}\n")?;
405+
write!(fd, " for c in '\\u{{e000}}'..='\\u{{10ffff}}' {{\n")?;
406+
write!(fd, " let _ = get_{}(c);\n", name)?;
407+
write!(fd, " }}\n")?;
408+
write!(fd, "}}\n\n")?;
409+
386410
return Ok(());
387411
}

src/ascii_hex_digit.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,15 @@ const ASCII_HEX_DIGIT_DATA: [u8; 15] = [
5959
};
6060
}
6161

62+
#[cfg(all(test, not(debug_assertions)))]
63+
#[test]
64+
fn ascii_hex_digit_full_coverage()
65+
{
66+
for c in '\u{0000}'..='\u{d7ff}' {
67+
let _ = get_ascii_hex_digit(c);
68+
}
69+
for c in '\u{e000}'..='\u{10ffff}' {
70+
let _ = get_ascii_hex_digit(c);
71+
}
72+
}
73+

src/bidi_control.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,15 @@ const BIDI_CONTROL_DATA: [u8; 66] = [
6060
};
6161
}
6262

63+
#[cfg(all(test, not(debug_assertions)))]
64+
#[test]
65+
fn bidi_control_full_coverage()
66+
{
67+
for c in '\u{0000}'..='\u{d7ff}' {
68+
let _ = get_bidi_control(c);
69+
}
70+
for c in '\u{e000}'..='\u{10ffff}' {
71+
let _ = get_bidi_control(c);
72+
}
73+
}
74+

src/composition_exclusion.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,15 @@ const COMPOSITION_EXCLUSION_DATA: [u8; 433] = [
7171
};
7272
}
7373

74+
#[cfg(all(test, not(debug_assertions)))]
75+
#[test]
76+
fn composition_exclusion_full_coverage()
77+
{
78+
for c in '\u{0000}'..='\u{d7ff}' {
79+
let _ = get_composition_exclusion(c);
80+
}
81+
for c in '\u{e000}'..='\u{10ffff}' {
82+
let _ = get_composition_exclusion(c);
83+
}
84+
}
85+

src/dash.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,15 @@ const DASH_DATA: [u8; 497] = [
7373
};
7474
}
7575

76+
#[cfg(all(test, not(debug_assertions)))]
77+
#[test]
78+
fn dash_full_coverage()
79+
{
80+
for c in '\u{0000}'..='\u{d7ff}' {
81+
let _ = get_dash(c);
82+
}
83+
for c in '\u{e000}'..='\u{10ffff}' {
84+
let _ = get_dash(c);
85+
}
86+
}
87+

src/deprecated.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,15 @@ const DEPRECATED_DATA: [u8; 1186] = [
9595
};
9696
}
9797

98+
#[cfg(all(test, not(debug_assertions)))]
99+
#[test]
100+
fn deprecated_full_coverage()
101+
{
102+
for c in '\u{0000}'..='\u{d7ff}' {
103+
let _ = get_deprecated(c);
104+
}
105+
for c in '\u{e000}'..='\u{10ffff}' {
106+
let _ = get_deprecated(c);
107+
}
108+
}
109+

src/diacritic.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,15 @@ const DIACRITIC_DATA: [u8; 2507] = [
136136
};
137137
}
138138

139+
#[cfg(all(test, not(debug_assertions)))]
140+
#[test]
141+
fn diacritic_full_coverage()
142+
{
143+
for c in '\u{0000}'..='\u{d7ff}' {
144+
let _ = get_diacritic(c);
145+
}
146+
for c in '\u{e000}'..='\u{10ffff}' {
147+
let _ = get_diacritic(c);
148+
}
149+
}
150+

0 commit comments

Comments
 (0)