|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "reflect" |
| 5 | + "testing" |
| 6 | +) |
| 7 | + |
| 8 | +func TestSplitAndAdd(t *testing.T) { |
| 9 | + s := SplitAndAdd([]int{1, 2, 3, 4, 5}, 2) |
| 10 | + if !reflect.DeepEqual(s, []int{5, 10}) { |
| 11 | + t.Errorf("SplitAndAdd was incorrect, got: %d, want %d.", s, []int{5, 10}) |
| 12 | + } |
| 13 | + |
| 14 | + s = SplitAndAdd([]int{15}, 3) |
| 15 | + if !reflect.DeepEqual(s, []int{15}) { |
| 16 | + t.Errorf("SplitAndAdd was incorrect, got: %d, want %d.", s, []int{15}) |
| 17 | + } |
| 18 | + s = SplitAndAdd([]int{1, 2, 3, 4}, 1) |
| 19 | + if !reflect.DeepEqual(s, []int{4, 6}) { |
| 20 | + t.Errorf("SplitAndAdd was incorrect, got: %d, want %d.", s, []int{4, 6}) |
| 21 | + } |
| 22 | + s = SplitAndAdd([]int{1, 2, 3, 4, 5, 6}, 20) |
| 23 | + if !reflect.DeepEqual(s, []int{21}) { |
| 24 | + t.Errorf("SplitAndAdd was incorrect, got: %d, want %d.", s, []int{21}) |
| 25 | + } |
| 26 | + s = SplitAndAdd([]int{32, 45, 43, 23, 54, 23, 54, 34}, 2) |
| 27 | + if !reflect.DeepEqual(s, []int{183, 125}) { |
| 28 | + t.Errorf("SplitAndAdd was incorrect, got: %d, want %d.", s, []int{183, 125}) |
| 29 | + } |
| 30 | + s = SplitAndAdd([]int{32, 45, 43, 23, 54, 23, 54, 34}, 0) |
| 31 | + if !reflect.DeepEqual(s, []int{32, 45, 43, 23, 54, 23, 54, 34}) { |
| 32 | + t.Errorf("SplitAndAdd was incorrect, got: %d, want %d.", s, []int{32, 45, 43, 23, 54, 23, 54, 34}) |
| 33 | + } |
| 34 | + // s = SplitAndAdd([]int{3, 234, 25, 345, 45, 34, 234, 235, 345}, 3) |
| 35 | + // if !reflect.DeepEqual(s, []int{305, 1195}) { |
| 36 | + // t.Errorf("SplitAndAdd was incorrect, got: %d, want %d.", s, []int{305, 1195}) |
| 37 | + // } |
| 38 | + // s = SplitAndAdd([]int{3, 234, 25, 345, 45, 34, 234, 235, 345, 34, 534, 45, 645, 645, 645, 4656, 45, 3}, 4) |
| 39 | + // if !reflect.DeepEqual(s, []int{1040, 7712}) { |
| 40 | + // t.Errorf("SplitAndAdd was incorrect, got: %d, want %d.", s, []int{1040, 7712}) |
| 41 | + // } |
| 42 | + // s = SplitAndAdd([]int{23, 345, 345, 345, 34536, 567, 568, 6, 34536, 54, 7546, 456}, 20) |
| 43 | + // if !reflect.DeepEqual(s, []int{79327}) { |
| 44 | + // t.Errorf("SplitAndAdd was incorrect, got: %d, want %d.", s, []int{79327}) |
| 45 | + // } |
| 46 | +} |
0 commit comments