Logo

index : blog

---

  • summary
  • about
  • tree
  • log
  • branches
<< path: root/public/blog.git/html/modules/uniform/tests/010_char_class/negate.spec.jai blob: 41244f4ad9a2dd9d435fff42229a362e05a23bd6 [raw] [clear marker]

        
0converts_a_full_range_into_an_empty_one :: () {
1 char_class: CharClass;
2 defer uninit(*char_class);
3 add_range(*char_class, 0, Runemax);
4
5 negate(*char_class);
6
7 assert_that(char_class.ranges.count, is(0));
8} @Test
9
10converts_an_empty_range_into_a_full_one :: () {
11 char_class: CharClass;
12 defer uninit(*char_class);
13
14 negate(*char_class);
15
16 assert_that(char_class.ranges, contains_items(
17 make_range(0, Runemax),
18 is_equal = equal_range));
19} @Test
20
21// ToDo: report error if this still crashes with beta >=031
22// Simple_Range_Test_Args :: struct {
23// input: [] RuneRange;
24// expected: [] RuneRange;
25// };
26
27// converts_a_partial_range_into_the_rest_params :: Simple_Range_Test_Args.[
28// .{
29// RuneRange.[],
30// RuneRange.[.{0, Runemax}]
31// },
32// .{
33// RuneRange.[.{0, Runemax}],
34// RuneRange.[]
35// },
36// .{
37// RuneRange.[.{0, 100}],
38// RuneRange.[.{101, Runemax}]
39// },
40// ];
41
42Simple_Range_Test_Args :: struct {
43 input: RuneRange;
44 expected: RuneRange;
45};
46
47converts_a_partial_range_into_the_rest_params :: Simple_Range_Test_Args.[
48 .{
49 .{0, 100},
50 .{101, Runemax}
51 },
52 .{
53 .{100, Runemax},
54 .{0, 99},
55 },
56];
57
58converts_a_partial_range_into_the_rest :: (args: Simple_Range_Test_Args) {
59 char_class: CharClass;
60 defer uninit(*char_class);
61 add_range(*char_class, args.input.lo, args.input.hi);
62
63 negate(*char_class);
64
65 assert_that(char_class.ranges, contains_items(
66 args.expected,
67 is_equal = equal_range));
68} @Test
69
70converts_all_ranges_correctly :: () {
71 char_class: CharClass;
72 defer uninit(*char_class);
73 add_range(*char_class, 100, 150);
74 add_range(*char_class, 160, 170);
75
76 negate(*char_class);
77
78 assert_that(char_class.ranges, contains_items(
79 make_range(0, 99),
80 make_range(151, 159),
81 make_range(171, Runemax),
82 is_equal = equal_range));
83} @Test
84
85converts_all_ranges_correctly_2 :: () {
86 char_class: CharClass;
87 add_range(*char_class, 0, 100);
88 add_range(*char_class, 200, Runemax);
89
90 negate(*char_class);
91
92 assert_that(char_class.ranges, contains_items(
93 make_range(101, 199),
94 is_equal = equal_range));
95} @Test
96
97#scope_file
98
99equal_range :: (a: RuneRange, b: RuneRange) -> bool {
100 return a.lo == b.lo && a.hi == b.hi;
101}
102
Copyright 2026  E766CB298A6D1E64 | Git-Thing heavily inspired by cgit