trackler 2.0.6.22 → 2.0.6.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/exercises/book-store/canonical-data.json +61 -80
- data/common/exercises/etl/canonical-data.json +69 -0
- data/lib/trackler/version.rb +1 -1
- data/tracks/go/config.json +10 -4
- data/tracks/java/config.json +13 -1
- data/tracks/java/exercises/diamond/build.gradle +17 -0
- data/tracks/java/exercises/diamond/src/example/java/DiamondPrinter.java +41 -0
- data/tracks/java/exercises/diamond/src/main/java/DiamondPrinter.java +5 -0
- data/tracks/java/exercises/diamond/src/test/java/DiamondPrinterTest.java +111 -0
- data/tracks/java/exercises/grade-school/src/example/java/School.java +20 -19
- data/tracks/java/exercises/grade-school/src/test/java/SchoolTest.java +53 -20
- data/tracks/java/exercises/secret-handshake/build.gradle +17 -0
- data/tracks/java/exercises/secret-handshake/src/example/java/HandshakeCalculator.java +29 -0
- data/tracks/java/exercises/secret-handshake/src/example/java/Signal.java +1 -0
- data/tracks/java/exercises/secret-handshake/src/main/java/HandshakeCalculator.java +5 -0
- data/tracks/java/exercises/secret-handshake/src/main/java/Signal.java +5 -0
- data/tracks/java/exercises/secret-handshake/src/test/java/HandshakeCalculatorTest.java +106 -0
- data/tracks/java/exercises/settings.gradle +2 -0
- data/tracks/julia/config.json +42 -0
- data/tracks/julia/exercises/bob/bob.jl +3 -0
- data/tracks/julia/exercises/bob/example.jl +30 -0
- data/tracks/julia/exercises/bob/runtests.jl +70 -0
- data/tracks/julia/exercises/difference-of-squares/difference-of-squares.jl +14 -0
- data/tracks/julia/exercises/difference-of-squares/example.jl +9 -0
- data/tracks/julia/exercises/difference-of-squares/runtests.jl +22 -0
- data/tracks/julia/exercises/hamming/example.jl +5 -0
- data/tracks/julia/exercises/hamming/hamming.jl +3 -0
- data/tracks/julia/exercises/hamming/runtests.jl +42 -0
- data/tracks/julia/exercises/hello-world/example.jl +3 -0
- data/tracks/julia/exercises/hello-world/hello-world.jl +3 -0
- data/tracks/julia/exercises/hello-world/runtests.jl +12 -0
- data/tracks/julia/exercises/word-count/example.jl +9 -0
- data/tracks/julia/exercises/word-count/runtests.jl +47 -0
- data/tracks/julia/exercises/word-count/word-count.jl +3 -0
- data/tracks/objective-c/config.json +10 -0
- data/tracks/objective-c/exercises/flatten-array/FlattenArrayExample.h +6 -0
- data/tracks/objective-c/exercises/flatten-array/FlattenArrayExample.m +48 -0
- data/tracks/objective-c/exercises/flatten-array/FlattenArrayTest.m +110 -0
- data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +33 -0
- data/tracks/ocaml/config.json +5 -0
- data/tracks/ocaml/exercises/pangram/.merlin +3 -0
- data/tracks/ocaml/exercises/pangram/Makefile +11 -0
- data/tracks/ocaml/exercises/pangram/example.ml +9 -0
- data/tracks/ocaml/exercises/pangram/pangram.mli +1 -0
- data/tracks/ocaml/exercises/pangram/test.ml +29 -0
- data/tracks/ocaml/tools/test-generator/templates/pangram/template.ml +15 -0
- data/tracks/pascal/config.json +8 -0
- data/tracks/pascal/docs/INSTALLATION.md +3 -3
- data/tracks/pascal/docs/img/07delphiclicklibrarypathbuttonLogo.png +0 -0
- data/tracks/pascal/exercises/grains/GrainsTests.dpr +60 -0
- data/tracks/pascal/exercises/grains/uGrainsExample.pas +33 -0
- data/tracks/pascal/exercises/grains/uGrainsTests.pas +149 -0
- data/tracks/perl6/SETUP.md +8 -2
- metadata +41 -2
@@ -0,0 +1,70 @@
|
|
1
|
+
using Base.Test
|
2
|
+
|
3
|
+
include("bob.jl")
|
4
|
+
|
5
|
+
questions = (
|
6
|
+
"Does this cryogenic chamber make me look fat?",
|
7
|
+
"You are, what, like 15?",
|
8
|
+
"fffbbcbeab?",
|
9
|
+
"4?", ":) ?",
|
10
|
+
"Wait! Hang on. Are you going to be OK?",
|
11
|
+
"Okay if like my spacebar quite a bit? ",
|
12
|
+
)
|
13
|
+
|
14
|
+
yells = (
|
15
|
+
"WATCH OUT!",
|
16
|
+
"FCECDFCAAB",
|
17
|
+
"WHAT THE HELL WERE YOU THINKING?",
|
18
|
+
"1, 2, 3 GO!",
|
19
|
+
"ZOMG THE %^*@#\$(*^ ZOMBIES ARE COMING!!11!!1!",
|
20
|
+
"I HATE YOU",
|
21
|
+
)
|
22
|
+
|
23
|
+
silences = (
|
24
|
+
"",
|
25
|
+
" ",
|
26
|
+
"\t\t\t\t\t\t\t\t\t\t",
|
27
|
+
"\n\r \t",
|
28
|
+
)
|
29
|
+
|
30
|
+
miscs = (
|
31
|
+
"Tom-ay-to, tom-aaaah-to.",
|
32
|
+
"Let's go make out behind the gym!",
|
33
|
+
"It's OK if you don't want to go to the DMV.",
|
34
|
+
"1, 2, 3",
|
35
|
+
"Ending with ? means a question.",
|
36
|
+
"\nDoes this cryogenic chamber make me look fat?\nno",
|
37
|
+
" hmmmmmmm...",
|
38
|
+
"This is a statement ending with whitespace ",
|
39
|
+
)
|
40
|
+
|
41
|
+
response = Dict(
|
42
|
+
:question => "Sure.",
|
43
|
+
:yelling => "Whoa, chill out!",
|
44
|
+
:silence => "Fine. Be that way!",
|
45
|
+
:misc => "Whatever."
|
46
|
+
)
|
47
|
+
|
48
|
+
@testset "questions" begin
|
49
|
+
@testset "$question" for question in questions
|
50
|
+
@test bob(question) == response[:question]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
@testset "yelling" begin
|
55
|
+
@testset "$yell" for yell in yells
|
56
|
+
@test bob(yell) == response[:yelling]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
@testset "silence" begin
|
61
|
+
@testset "$silence" for silence in silences
|
62
|
+
@test bob(silence) == response[:silence]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
@testset "misc" begin
|
67
|
+
@testset "$misc" for misc in miscs
|
68
|
+
@test bob(misc) == response[:misc]
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"Square the sum of the numbers up to the given number"
|
2
|
+
function sum_of_squares(n::Int)
|
3
|
+
|
4
|
+
end
|
5
|
+
|
6
|
+
"Sum the squares of the numbers up to the given number"
|
7
|
+
function square_of_sum(n::Int)
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
"Subtract sum of squares from square of sums"
|
12
|
+
function difference(n::Int)
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# This uses reduce instead of sum because sum can't handle empty collections properly.
|
2
|
+
# There is no universal zero-element, so it has to be specified manually and cannot
|
3
|
+
# be determined automatically. Otherwise, n=0 will cause an error.
|
4
|
+
sum_of_squares(n::Int) = reduce(+, 0, i^2 for i in 1:n)
|
5
|
+
|
6
|
+
# However, sum{T<:Real}(r::Range{T}) can handle "empty" ranges.
|
7
|
+
square_of_sum(n::Int) = sum(1:n)^2
|
8
|
+
|
9
|
+
difference(n::Int) = square_of_sum(n) - sum_of_squares(n)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
using Base.Test
|
2
|
+
|
3
|
+
include("difference-of-squares.jl")
|
4
|
+
|
5
|
+
@testset "Square the sum of the numbers up to the given number" begin
|
6
|
+
@test square_of_sum(5) == 225
|
7
|
+
@test square_of_sum(10) == 3025
|
8
|
+
@test square_of_sum(100) == 25502500
|
9
|
+
end
|
10
|
+
|
11
|
+
@testset "Sum the squares of the numbers up to the given number" begin
|
12
|
+
@test sum_of_squares(5) == 55
|
13
|
+
@test sum_of_squares(10) == 385
|
14
|
+
@test sum_of_squares(100) == 338350
|
15
|
+
end
|
16
|
+
|
17
|
+
@testset "Subtract sum of squares from square of sums" begin
|
18
|
+
@test difference(0) == 0
|
19
|
+
@test difference(5) == 170
|
20
|
+
@test difference(10) == 2640
|
21
|
+
@test difference(100) == 25164150
|
22
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
using Base.Test
|
2
|
+
|
3
|
+
include("hamming.jl")
|
4
|
+
|
5
|
+
@testset "identical strands" begin
|
6
|
+
@test distance("A", "A") == 0
|
7
|
+
@test distance("GGACTGA", "GGACTGA") == 0
|
8
|
+
end
|
9
|
+
|
10
|
+
@testset "complete distance" begin
|
11
|
+
@test distance("A", "G") == 1
|
12
|
+
@test distance("AG", "CT") == 2
|
13
|
+
end
|
14
|
+
|
15
|
+
@testset "small distance" begin
|
16
|
+
@test distance("AT", "CT") == 1
|
17
|
+
@test distance("GGACG", "GGTCG") == 1
|
18
|
+
@test distance("ACCAGGG", "ACTATGG") == 2
|
19
|
+
end
|
20
|
+
|
21
|
+
@testset "non-unique characters" begin
|
22
|
+
@test distance("AGA", "AGG") == 1
|
23
|
+
@test distance("AGG", "AGA") == 1
|
24
|
+
end
|
25
|
+
|
26
|
+
@testset "same nucleotides in different positions" begin
|
27
|
+
@test distance("TAG", "GAT") == 2
|
28
|
+
end
|
29
|
+
|
30
|
+
@testset "large distance" begin
|
31
|
+
@test distance("GATACA", "GCATAA") == 4
|
32
|
+
@test distance("GGACGGATTCTG", "AGGACGGATTCT") == 9
|
33
|
+
end
|
34
|
+
|
35
|
+
@testset "empty strands" begin
|
36
|
+
@test distance("", "") == 0
|
37
|
+
end
|
38
|
+
|
39
|
+
@testset "different strand lengths" begin
|
40
|
+
@test_throws ArgumentError distance("AATG", "AAA")
|
41
|
+
@test_throws ArgumentError distance("ATA", "AGTG")
|
42
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
using Base.Test
|
2
|
+
|
3
|
+
include("word-count.jl")
|
4
|
+
|
5
|
+
@testset "no words" begin
|
6
|
+
@test wordcount(" .\n,\t!^&*()~@#\$%{}[]:;'/<>") == Dict()
|
7
|
+
end
|
8
|
+
|
9
|
+
@testset "count one word" begin
|
10
|
+
@test wordcount("word") == Dict("word" => 1)
|
11
|
+
end
|
12
|
+
|
13
|
+
@testset "count one of each word" begin
|
14
|
+
@test wordcount("one of each") == Dict("one" => 1, "of" => 1, "each" => 1)
|
15
|
+
end
|
16
|
+
|
17
|
+
@testset "multiple occurrences of a word" begin
|
18
|
+
@test wordcount("one fish two fish red fish blue fish") == Dict("one" => 1, "fish" => 4, "two" => 1, "red" => 1, "blue" => 1)
|
19
|
+
end
|
20
|
+
|
21
|
+
@testset "handles cramped lists" begin
|
22
|
+
@test wordcount("one,two,three") == Dict("one" => 1, "two" => 1, "three" => 1)
|
23
|
+
end
|
24
|
+
|
25
|
+
@testset "handles expanded lists" begin
|
26
|
+
@test wordcount("one,\ntwo,\nthree") == Dict("one" => 1, "two" => 1, "three" => 1)
|
27
|
+
end
|
28
|
+
|
29
|
+
@testset "ignore punctuation" begin
|
30
|
+
@test wordcount("car: carpet as java: javascript!!&@\$%^&") == Dict("car" => 1, "carpet" => 1, "as" => 1, "java" => 1, "javascript" => 1)
|
31
|
+
end
|
32
|
+
|
33
|
+
@testset "include numbers" begin
|
34
|
+
@test wordcount("testing, 1, 2 testing") == Dict("testing" => 2, "1" => 1, "2" => 1)
|
35
|
+
end
|
36
|
+
|
37
|
+
@testset "normalize case" begin
|
38
|
+
@test wordcount("go Go GO Stop stop") == Dict("go" => 3, "stop" => 2)
|
39
|
+
end
|
40
|
+
|
41
|
+
@testset "with apostrophes" begin
|
42
|
+
@test wordcount("First: don't laugh. Then: don't cry.") == Dict("first" => 1, "don't" => 2, "laugh" => 1, "then" => 1, "cry" => 1)
|
43
|
+
end
|
44
|
+
|
45
|
+
@testset "with quotations" begin
|
46
|
+
@test wordcount("Joe can't tell between 'large' and large.") == Dict("joe" => 1, "can't" => 1, "tell" => 1, "between" => 1, "large" => 2, "and" => 1)
|
47
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#import "FlattenArrayExample.h"
|
2
|
+
static NSMutableArray *resultArray;
|
3
|
+
static NSNull *nullValue;
|
4
|
+
|
5
|
+
@implementation FlattenArrayExample
|
6
|
+
|
7
|
+
+ (NSArray*)flattenArray:(NSArray *)list{
|
8
|
+
|
9
|
+
resultArray = [NSMutableArray array];
|
10
|
+
nullValue = [NSNull null];
|
11
|
+
for(int i=0;i < list.count;i++){
|
12
|
+
|
13
|
+
if([list[i] isKindOfClass:[NSArray class]]){
|
14
|
+
|
15
|
+
[FlattenArrayExample extractValuesFromArray:list[i]];
|
16
|
+
|
17
|
+
}else{
|
18
|
+
|
19
|
+
if(list[i] != nullValue){
|
20
|
+
|
21
|
+
[resultArray addObject:list[i]];
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
return resultArray;
|
26
|
+
}
|
27
|
+
|
28
|
+
|
29
|
+
+(void)extractValuesFromArray:(NSArray*)array{
|
30
|
+
|
31
|
+
for(int i=0;i < array.count;i++){
|
32
|
+
|
33
|
+
if([array[i] isKindOfClass:[NSArray class]]){
|
34
|
+
|
35
|
+
[FlattenArrayExample extractValuesFromArray:array[i]];
|
36
|
+
}else{
|
37
|
+
|
38
|
+
if(array[i] != nullValue){
|
39
|
+
|
40
|
+
[resultArray addObject:array[i]];
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
@end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
#import <XCTest/XCTest.h>
|
2
|
+
|
3
|
+
#if __has_include("FlattenArrayExample.h")
|
4
|
+
# import "FlattenArrayExample.h"
|
5
|
+
# else
|
6
|
+
# import "FlattenArray.h"
|
7
|
+
#endif
|
8
|
+
|
9
|
+
@interface FlattenArrayTest : XCTestCase
|
10
|
+
|
11
|
+
@end
|
12
|
+
|
13
|
+
@implementation FlattenArrayTest
|
14
|
+
|
15
|
+
- (void)testFlattenArrayWithJustIntegers {
|
16
|
+
|
17
|
+
NSArray *innerArray = [NSArray arrayWithObjects:[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:4],[NSNumber numberWithInt:5],[NSNumber numberWithInt:6],[NSNumber numberWithInt:7], nil];
|
18
|
+
NSArray *inputArray = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],innerArray,[NSNumber numberWithInt:8], nil];
|
19
|
+
NSArray *expected = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:4],[NSNumber numberWithInt:5],[NSNumber numberWithInt:6],[NSNumber numberWithInt:7],[NSNumber numberWithInt:8], nil];
|
20
|
+
XCTAssertTrue([expected isEqualToArray:[FlattenArrayExample flattenArray:inputArray]]);
|
21
|
+
|
22
|
+
|
23
|
+
}
|
24
|
+
|
25
|
+
-(void)testFiveLevelNesting{
|
26
|
+
|
27
|
+
NSArray *innerArray5 = [NSArray arrayWithObject:[NSNumber numberWithInt:50]];
|
28
|
+
NSArray *innerArray4 = [NSArray arrayWithObject:innerArray5];
|
29
|
+
NSArray *innerArray3 = [NSArray arrayWithObject:innerArray4];
|
30
|
+
NSArray *innerArray2 = [NSArray arrayWithObjects:[NSNumber numberWithInt:2],[NSNumber numberWithInt:3], nil];
|
31
|
+
NSArray *innerArray1 = [NSArray arrayWithObjects:innerArray2,[NSNumber numberWithInt:8],[NSNumber numberWithInt:100],[NSNumber numberWithInt:4],innerArray3, nil];
|
32
|
+
NSArray *inputArray = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:2],innerArray1,[NSNumber numberWithInt:-2], nil];
|
33
|
+
|
34
|
+
NSArray *expected = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:2],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:8],[NSNumber numberWithInt:100],[NSNumber numberWithInt:4],[NSNumber numberWithInt:50],[NSNumber numberWithInt:-2], nil];
|
35
|
+
XCTAssertTrue([expected isEqualToArray:[FlattenArrayExample flattenArray:inputArray]]);
|
36
|
+
}
|
37
|
+
|
38
|
+
-(void)testSixLevelNesting{
|
39
|
+
|
40
|
+
NSArray *innerArray6 = [NSArray arrayWithObject:[NSNumber numberWithInt:5]];
|
41
|
+
NSArray *innerArray5 = [NSArray arrayWithObject:innerArray6];
|
42
|
+
NSArray *innerArray4 = [NSArray arrayWithObjects:[NSNumber numberWithInt:4],innerArray5, nil];
|
43
|
+
NSArray *innerArray3 = [NSArray arrayWithObject:[NSNumber numberWithInt:3]];
|
44
|
+
NSArray *innerArray2 = [NSArray arrayWithObject:innerArray3];
|
45
|
+
NSArray *innerArray1 = [NSArray arrayWithObjects:[NSNumber numberWithInt:2],innerArray2,innerArray4,[NSNumber numberWithInt:6],[NSNumber numberWithInt:7], nil];
|
46
|
+
NSArray *inputArray = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],innerArray1,[NSNumber numberWithInt:8], nil];
|
47
|
+
NSArray *expected = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:4],[NSNumber numberWithInt:5],[NSNumber numberWithInt:6],[NSNumber numberWithInt:7],[NSNumber numberWithInt:8], nil];
|
48
|
+
XCTAssertTrue([expected isEqualToArray:[FlattenArrayExample flattenArray:inputArray]]);
|
49
|
+
}
|
50
|
+
|
51
|
+
-(void)testSixLevelNestingWithNullValues{
|
52
|
+
|
53
|
+
NSNull *nullValue = [NSNull null];
|
54
|
+
NSArray *innerArray6 = [NSArray arrayWithObject:nullValue];
|
55
|
+
NSArray *innerArray5 = [NSArray arrayWithObject:innerArray6];
|
56
|
+
NSArray *innerArray4 = [NSArray arrayWithObject:[NSNumber numberWithInt:100]];
|
57
|
+
NSArray *innerArray3 = [NSArray arrayWithObject:innerArray4];
|
58
|
+
NSArray *innerArray2 = [NSArray arrayWithObjects:[NSNumber numberWithInt:2],[NSNumber numberWithInt:3], nil];
|
59
|
+
NSArray *innerArray1 = [NSArray arrayWithObjects:innerArray2,[NSNumber numberWithInt:8],innerArray3,nullValue,innerArray5, nil];
|
60
|
+
NSArray *inputArray = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:2],innerArray1,[NSNumber numberWithInt:-2], nil];
|
61
|
+
NSArray *expected = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:2],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:8],[NSNumber numberWithInt:100],[NSNumber numberWithInt:-2], nil];
|
62
|
+
XCTAssertTrue([expected isEqualToArray:[FlattenArrayExample flattenArray:inputArray]]);
|
63
|
+
|
64
|
+
}
|
65
|
+
|
66
|
+
-(void)testAllValuesInNestedListAreNull{
|
67
|
+
|
68
|
+
NSNull *nullValue = [NSNull null];
|
69
|
+
NSArray *innerArray6 = [NSArray arrayWithObjects:nullValue,nullValue, nil];
|
70
|
+
NSArray *innerArray5 = [NSArray arrayWithObjects:innerArray6,nullValue, nil];
|
71
|
+
NSArray *innerArray4 = [NSArray arrayWithObject:nullValue];
|
72
|
+
NSArray *innerArray3 = [NSArray arrayWithObject:innerArray4];
|
73
|
+
NSArray *innerArray2 = [NSArray arrayWithObject:innerArray3];
|
74
|
+
NSArray *innerArray1 = [NSArray arrayWithObject:innerArray2];
|
75
|
+
NSArray *inputArray = [NSArray arrayWithObjects:nullValue,innerArray1,nullValue,nullValue,innerArray5,nullValue, nil];
|
76
|
+
NSArray *expected = @[];
|
77
|
+
XCTAssertTrue([expected isEqualToArray:[FlattenArrayExample flattenArray:inputArray]]);
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
-(void)testFiveLevelDeepNestedListWithDoubleValuesAndNullValues{
|
82
|
+
|
83
|
+
NSNull *nullValue = [NSNull null];
|
84
|
+
NSArray *innerArray5 = [NSArray arrayWithObject:nullValue];
|
85
|
+
NSArray *innerArray4 = [NSArray arrayWithObject:innerArray5];
|
86
|
+
NSArray *innerArray3 = [NSArray arrayWithObject:innerArray4];
|
87
|
+
NSArray *innerArray2 = [NSArray arrayWithObjects:[NSNumber numberWithDouble:2.00005],[NSNumber numberWithDouble:3.13], nil];
|
88
|
+
NSArray *innerArray1 = [NSArray arrayWithObjects:innerArray2,[NSNumber numberWithDouble:8.4],[NSNumber numberWithDouble:100],[NSNumber numberWithDouble:4.8],innerArray3, nil];
|
89
|
+
NSArray *inputArray = [NSArray arrayWithObjects:[NSNumber numberWithDouble:0.085],[NSNumber numberWithDouble:2.8844557],innerArray1,[NSNumber numberWithDouble:-2.5], nil];
|
90
|
+
|
91
|
+
NSArray *expected = [NSArray arrayWithObjects:[NSNumber numberWithDouble:0.085],[NSNumber numberWithDouble:2.8844557],[NSNumber numberWithDouble:2.00005],[NSNumber numberWithDouble:3.13],[NSNumber numberWithDouble:8.4],[NSNumber numberWithDouble:100],[NSNumber numberWithDouble:4.8],[NSNumber numberWithDouble:-2.5], nil];
|
92
|
+
XCTAssertTrue([expected isEqualToArray:[FlattenArrayExample flattenArray:inputArray]]);
|
93
|
+
|
94
|
+
}
|
95
|
+
|
96
|
+
-(void)testSixLevelDeepNestedListWithStringsAndNullValues{
|
97
|
+
|
98
|
+
NSNull *nullValue = [NSNull null];
|
99
|
+
NSArray *innerArray6 = [NSArray arrayWithObject:nullValue];
|
100
|
+
NSArray *innerArray5 = [NSArray arrayWithObject:innerArray6];
|
101
|
+
NSArray *innerArray4 = [NSArray arrayWithObject:@"One Hundred"];
|
102
|
+
NSArray *innerArray3 = [NSArray arrayWithObject:innerArray4];
|
103
|
+
NSArray *innerArray2 = [NSArray arrayWithObjects:@"Two",@"three", nil];
|
104
|
+
NSArray *innerArray1 = [NSArray arrayWithObjects:innerArray2,@"eight",innerArray3,nullValue,innerArray5, nil];
|
105
|
+
NSArray *inputArray = [NSArray arrayWithObjects:@"Zero",@"two",innerArray1,@"minus two", nil];
|
106
|
+
NSArray *expected = [NSArray arrayWithObjects:@"Zero",@"two",@"Two",@"three",@"eight",@"One Hundred",@"minus two", nil];
|
107
|
+
XCTAssertTrue([expected isEqualToArray:[FlattenArrayExample flattenArray:inputArray]]);
|
108
|
+
|
109
|
+
}
|
110
|
+
@end
|