-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbasic_test.dart
40 lines (36 loc) · 974 Bytes
/
basic_test.dart
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
import "package:flutter_test/flutter_test.dart";
void main() {
// 使用 expect 來驗證 String functions
group('easy tests for string.', () {
test('split() test', () {
var string = "apple,banana,cat,dog";
expect(string.split(","), equals(["apple", "banana", "cat", "dog"]));
});
test('trim() test', () {
var string = " abc";
expect(string.trim(), equals("abc"));
});
});
// 使用 expect 來驗證 Int functions
group('easy test for integer.', () {
test('integer compare', () {
expect(1 > 2, false);
});
test('base 16 radix', () {
expect(12.toRadixString(16), 'c');
});
});
// Expect 可以使用各種 function 來搭配,進行複雜驗證
// contains
// isNot
// startsWith, endsWith
test('split() test.', () {
expect(
"abc,def,ghi",
allOf([
contains(",def"),
isNot(startsWith('def')),
endsWith('hi'),
]));
});
}