mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
deinit more in tests
This commit is contained in:
parent
e0f88a5de2
commit
ef258fe675
1 changed files with 70 additions and 8 deletions
|
@ -320,9 +320,7 @@ test "strSplitInPlace: no delimiter" {
|
||||||
str,
|
str,
|
||||||
};
|
};
|
||||||
|
|
||||||
expectEqual(array.len, expected.len);
|
defer {
|
||||||
expect(array[0].eq(expected[0]));
|
|
||||||
|
|
||||||
for (array) |rocStr| {
|
for (array) |rocStr| {
|
||||||
rocStr.deinit(testing.allocator);
|
rocStr.deinit(testing.allocator);
|
||||||
}
|
}
|
||||||
|
@ -330,6 +328,13 @@ test "strSplitInPlace: no delimiter" {
|
||||||
for (expected) |rocStr| {
|
for (expected) |rocStr| {
|
||||||
rocStr.deinit(testing.allocator);
|
rocStr.deinit(testing.allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
str.deinit(testing.allocator);
|
||||||
|
delimiter.deinit(testing.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
expectEqual(array.len, expected.len);
|
||||||
|
expect(array[0].eq(expected[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
test "strSplitInPlace: empty end" {
|
test "strSplitInPlace: empty end" {
|
||||||
|
@ -355,6 +360,19 @@ test "strSplitInPlace: empty end" {
|
||||||
one, two, RocStr.empty(),
|
one, two, RocStr.empty(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defer {
|
||||||
|
for (array) |rocStr| {
|
||||||
|
rocStr.deinit(testing.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (expected) |rocStr| {
|
||||||
|
rocStr.deinit(testing.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
str.deinit(testing.allocator);
|
||||||
|
delimiter.deinit(testing.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
expectEqual(array.len, expected.len);
|
expectEqual(array.len, expected.len);
|
||||||
expect(array[0].eq(expected[0]));
|
expect(array[0].eq(expected[0]));
|
||||||
expect(array[1].eq(expected[1]));
|
expect(array[1].eq(expected[1]));
|
||||||
|
@ -383,6 +401,19 @@ test "strSplitInPlace: delimiter on sides" {
|
||||||
RocStr.empty(), ghi, RocStr.empty(),
|
RocStr.empty(), ghi, RocStr.empty(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defer {
|
||||||
|
for (array) |rocStr| {
|
||||||
|
rocStr.deinit(testing.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (expected) |rocStr| {
|
||||||
|
rocStr.deinit(testing.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
str.deinit(testing.allocator);
|
||||||
|
delimiter.deinit(testing.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
expectEqual(array.len, expected.len);
|
expectEqual(array.len, expected.len);
|
||||||
expect(array[0].eq(expected[0]));
|
expect(array[0].eq(expected[0]));
|
||||||
expect(array[1].eq(expected[1]));
|
expect(array[1].eq(expected[1]));
|
||||||
|
@ -411,6 +442,19 @@ test "strSplitInPlace: three pieces" {
|
||||||
a, b, c,
|
a, b, c,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defer {
|
||||||
|
for (array) |rocStr| {
|
||||||
|
rocStr.deinit(testing.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (expectedArray) |rocStr| {
|
||||||
|
rocStr.deinit(testing.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
str.deinit(testing.allocator);
|
||||||
|
delimiter.deinit(testing.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
expectEqual(expectedArray.len, array.len);
|
expectEqual(expectedArray.len, array.len);
|
||||||
expect(array[0].eq(expectedArray[0]));
|
expect(array[0].eq(expectedArray[0]));
|
||||||
expect(array[1].eq(expectedArray[1]));
|
expect(array[1].eq(expectedArray[1]));
|
||||||
|
@ -471,9 +515,17 @@ test "countSegments: long delimiter" {
|
||||||
const delimiterArr = "delimiter";
|
const delimiterArr = "delimiter";
|
||||||
const delimiter = RocStr.init(testing.allocator, delimiterArr, delimiterArr.len);
|
const delimiter = RocStr.init(testing.allocator, delimiterArr, delimiterArr.len);
|
||||||
|
|
||||||
|
defer {
|
||||||
|
str.deinit(testing.allocator);
|
||||||
|
delimiter.deinit(testing.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
const segmentsCount = countSegments(str, delimiter);
|
const segmentsCount = countSegments(str, delimiter);
|
||||||
|
|
||||||
expectEqual(segmentsCount, 1);
|
expectEqual(segmentsCount, 1);
|
||||||
|
|
||||||
|
str.deinit(testing.allocator);
|
||||||
|
delimiter.deinit(testing.allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "countSegments: delimiter at start" {
|
test "countSegments: delimiter at start" {
|
||||||
|
@ -485,6 +537,11 @@ test "countSegments: delimiter at start" {
|
||||||
const delimiterArr = "hello";
|
const delimiterArr = "hello";
|
||||||
const delimiter = RocStr.init(testing.allocator, delimiterArr, delimiterArr.len);
|
const delimiter = RocStr.init(testing.allocator, delimiterArr, delimiterArr.len);
|
||||||
|
|
||||||
|
defer {
|
||||||
|
str.deinit(testing.allocator);
|
||||||
|
delimiter.deinit(testing.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
const segmentsCount = countSegments(str, delimiter);
|
const segmentsCount = countSegments(str, delimiter);
|
||||||
|
|
||||||
expectEqual(segmentsCount, 2);
|
expectEqual(segmentsCount, 2);
|
||||||
|
@ -499,6 +556,11 @@ test "countSegments: delimiter interspered" {
|
||||||
const delimiterArr = "!";
|
const delimiterArr = "!";
|
||||||
const delimiter = RocStr.init(testing.allocator, delimiterArr, delimiterArr.len);
|
const delimiter = RocStr.init(testing.allocator, delimiterArr, delimiterArr.len);
|
||||||
|
|
||||||
|
defer {
|
||||||
|
str.deinit(testing.allocator);
|
||||||
|
delimiter.deinit(testing.allocator);
|
||||||
|
}
|
||||||
|
|
||||||
const segmentsCount = countSegments(str, delimiter);
|
const segmentsCount = countSegments(str, delimiter);
|
||||||
|
|
||||||
expectEqual(segmentsCount, 3);
|
expectEqual(segmentsCount, 3);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue