This repository has been archived by the owner on Feb 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrays_string_test.java
82 lines (72 loc) · 2.72 KB
/
Arrays_string_test.java
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
//
// Copyright 2016, Yahoo Inc.
// Copyrights licensed under the New BSD License.
// See the accompanying LICENSE file for terms.
//
package github.com.jminusminus.core;
import github.com.jminusminus.simplebdd.Test;
public class Arrays_string_test extends Test {
public static void main(String[] args) {
Arrays_string_test test = new Arrays_string_test();
test.run();
}
public void test_new_Arrays() {
this.should("return an instance of Arrays");
Arrays a = new Arrays();
this.assertEqual("github.com.jminusminus.core.Arrays", a.getClass().getName());
}
public void test_append() {
this.should("return an array with the new string");
String[] a = new String[]{"a", "b"};
String[] b = Arrays.append(a, "c");
this.assertEqual("a", b[0]);
this.assertEqual("b", b[1]);
this.assertEqual("c", b[2]);
this.assertEqual(3, b.length);
}
public void test_append_array() {
this.should("return an array with the new string array");
String[] a = new String[]{"a", "b"};
String[] b = new String[]{"c", "d"};
String[] c = Arrays.append(a, b);
this.assertEqual("a", c[0]);
this.assertEqual("b", c[1]);
this.assertEqual("c", c[2]);
this.assertEqual("d", c[3]);
this.assertEqual(4, c.length);
}
public void test_slice() {
this.should("return an array of the first three srings");
String[] a = new String[]{"a", "b", "c", "d"};
String[] b = Arrays.slice(a, 3);
this.assertEqual("a", b[0]);
this.assertEqual("b", b[1]);
this.assertEqual("c", b[2]);
this.assertEqual(3, b.length);
}
public void test_slice_negative() {
this.should("return an array of strings up to the the last -1");
String[] a = new String[]{"a", "b", "c", "d"};
String[] b = Arrays.slice(a, -1);
this.assertEqual("a", b[0]);
this.assertEqual("b", b[1]);
this.assertEqual("c", b[2]);
this.assertEqual(3, b.length);
}
public void test_slice_with_start() {
this.should("return an array of the middle two srings");
String[] a = new String[]{"a", "b", "c", "d"};
String[] b = Arrays.slice(a, 1, 3);
this.assertEqual("b", b[0]);
this.assertEqual("c", b[1]);
this.assertEqual(2, b.length);
}
public void test_slice_with_start_negitve_end() {
this.should("return an array of strings from the second item to the last -1");
String[] a = new String[]{"a", "b", "c", "d"};
String[] b = Arrays.slice(a, 1, -1);
this.assertEqual("b", b[0]);
this.assertEqual("c", b[1]);
this.assertEqual(2, b.length);
}
}