-
Notifications
You must be signed in to change notification settings - Fork 490
/
testing_test.cairo
126 lines (105 loc) · 2.39 KB
/
testing_test.cairo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use core::test::test_utils::assert_gt;
#[test]
#[should_panic(expected: ('panic_with_felt252()',))]
fn test_panic_with_felt252() {
// No semicolon here: Missing implementation for core::traits::Drop::<core::never>
core::panic_with_felt252('panic_with_felt252()')
}
#[test]
#[should_panic(expected: 'assert(false)')]
fn test_assert_false() {
assert(false, 'assert(false)');
}
#[test]
fn test_assert_true() {
assert(true, 'assert(true)');
}
#[test]
#[should_panic(expected: "assert(false)")]
fn test_assert_macro_false() {
assert!(false, "assert(false)");
}
#[test]
fn test_assert_macro_true() {
assert!(true, "assert(true)");
}
#[test]
fn test_assert_ne_with_description() {
assert_ne!(1, 2, "Description");
}
#[test]
fn test_assert_ne_no_description() {
assert_ne!(1, 2);
}
#[test]
fn test_assert_lt_with_description() {
assert_lt!(1, 2, "Description");
}
#[test]
fn test_assert_lt_no_description() {
assert_lt!(1, 2);
}
#[test]
fn test_assert_le_with_description() {
assert_le!(1, 2, "Description");
assert_le!(1, 1, "Description");
}
#[test]
fn test_assert_le_no_description() {
assert_le!(1, 2);
assert_le!(1, 1);
}
#[test]
fn test_assert_gt_with_description() {
assert_gt!(2, 1, "Description");
}
#[test]
fn test_assert_gt_no_description() {
assert_gt!(2, 1);
}
#[test]
fn test_assert_ge_with_description() {
assert_ge!(2, 1, "Description");
assert_ge!(2, 2, "Description");
}
#[test]
fn test_assert_ge_no_description() {
assert_ge!(2, 1);
assert_ge!(2, 2);
}
#[test]
#[should_panic(expected: "assertion failed: `false`.")]
fn test_assert_macro_no_input() {
assert!(false);
}
#[test]
#[should_panic(expected: "assertion `1 == 2` failed: Description
1: 1
2: 2")]
fn test_assert_eq_with_description() {
assert_eq!(1, 2, "Description");
}
#[test]
#[should_panic(expected: "assertion `1 == 2` failed: 1 != 2
1: 1
2: 2")]
fn test_assert_eq_with_formatted_description() {
assert_eq!(1, 2, "{} != {}", 1, 2);
}
#[test]
#[should_panic(expected: "assertion `1 == 2` failed.
1: 1
2: 2")]
fn test_assert_eq_no_description() {
assert_eq!(1, 2);
}
#[test]
#[available_gas(static)]
fn test_get_available_gas_no_gas_supply() {
assert_eq!(core::testing::get_available_gas(), 0)
}
#[test]
#[available_gas(10000)]
fn test_get_available_gas_with_gas_supply() {
assert_gt(core::testing::get_available_gas(), 5000, 'high amount of gas used')
}