Skip to content

Commit

Permalink
Add use of @name into test cases (tests compiling)
Browse files Browse the repository at this point in the history
  • Loading branch information
rooooooooob committed Nov 21, 2023
1 parent 83a0ede commit 7a08668
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
9 changes: 7 additions & 2 deletions tests/core/input.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ foo2 = #6.23([uint, opt_text])
bar = {
foo: #6.1337(foo),
? derp: uint,
1 : uint / null,
1 : uint / null, ; @name one
? 5: text,
five: 5,
float: float64,
Expand Down Expand Up @@ -125,16 +125,21 @@ top_level_array = [* uint]
top_level_single_elem = [uint]

overlapping_inlined = [
; @name one
0 //
; @name two
0, uint //
; @name three
0, uint, text
]

overlapping0 = [0]
overlapping1 = [0, uint]
overlapping2 = [0, uint, text]

overlapping = overlapping0 / overlapping1 / overlapping2
overlapping = overlapping0 ; @name A
/ overlapping1 ; @name B
/ overlapping2 ; @name C

array_opt_fields = [
? x: 1.010101
Expand Down
18 changes: 11 additions & 7 deletions tests/core/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ mod tests {

#[test]
fn bar() {
deser_test(&Bar::new(Foo::new(436, String::from("jfkdf"), vec![6, 4]), None, 3.3));
let mut bar = Bar::new(Foo::new(436, String::from("jfkdf"), vec![6, 4]), None, 3.3);
deser_test(&bar);
// tests @name
bar.one = Some(10);

}

#[test]
Expand Down Expand Up @@ -201,22 +205,22 @@ mod tests {

#[test]
fn overlapping() {
let overlap0 = Overlapping::new_overlapping0(Overlapping0::new());
let overlap0 = Overlapping::new_a(Overlapping0::new());
deser_test(&overlap0);
let overlap1 = Overlapping::new_overlapping1(Overlapping1::new(9));
let overlap1 = Overlapping::new_b(Overlapping1::new(9));
deser_test(&overlap1);
let overlap2 = Overlapping::new_overlapping2(Overlapping2::new(5, "overlapping".into()));
let overlap2 = Overlapping::new_c(Overlapping2::new(5, "overlapping".into()));
deser_test(&overlap2);
}

#[test]
fn overlapping_inlined() {
// this test won't work until https://github.com/dcSpark/cddl-codegen/issues/175 is resolved.
let overlap0 = OverlappingInlined::new_i0();
let overlap0 = OverlappingInlined::new_one();
deser_test(&overlap0);
let overlap1 = OverlappingInlined::new_overlapping_inlined1(9);
let overlap1 = OverlappingInlined::new_two(9);
//deser_test(&overlap1);
let overlap2 = OverlappingInlined::new_overlapping_inlined2(5, "overlapping".into());
let overlap2 = OverlappingInlined::new_three(5, "overlapping".into());
//deser_test(&overlap2);
}

Expand Down

0 comments on commit 7a08668

Please sign in to comment.