mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +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,16 +320,21 @@ test "strSplitInPlace: no delimiter" {
|
|||
str,
|
||||
};
|
||||
|
||||
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);
|
||||
expect(array[0].eq(expected[0]));
|
||||
|
||||
for (array) |rocStr| {
|
||||
rocStr.deinit(testing.allocator);
|
||||
}
|
||||
|
||||
for (expected) |rocStr| {
|
||||
rocStr.deinit(testing.allocator);
|
||||
}
|
||||
}
|
||||
|
||||
test "strSplitInPlace: empty end" {
|
||||
|
@ -355,6 +360,19 @@ test "strSplitInPlace: empty end" {
|
|||
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);
|
||||
expect(array[0].eq(expected[0]));
|
||||
expect(array[1].eq(expected[1]));
|
||||
|
@ -383,6 +401,19 @@ test "strSplitInPlace: delimiter on sides" {
|
|||
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);
|
||||
expect(array[0].eq(expected[0]));
|
||||
expect(array[1].eq(expected[1]));
|
||||
|
@ -411,6 +442,19 @@ test "strSplitInPlace: three pieces" {
|
|||
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);
|
||||
expect(array[0].eq(expectedArray[0]));
|
||||
expect(array[1].eq(expectedArray[1]));
|
||||
|
@ -471,9 +515,17 @@ test "countSegments: long delimiter" {
|
|||
const delimiterArr = "delimiter";
|
||||
const delimiter = RocStr.init(testing.allocator, delimiterArr, delimiterArr.len);
|
||||
|
||||
defer {
|
||||
str.deinit(testing.allocator);
|
||||
delimiter.deinit(testing.allocator);
|
||||
}
|
||||
|
||||
const segmentsCount = countSegments(str, delimiter);
|
||||
|
||||
expectEqual(segmentsCount, 1);
|
||||
|
||||
str.deinit(testing.allocator);
|
||||
delimiter.deinit(testing.allocator);
|
||||
}
|
||||
|
||||
test "countSegments: delimiter at start" {
|
||||
|
@ -485,6 +537,11 @@ test "countSegments: delimiter at start" {
|
|||
const delimiterArr = "hello";
|
||||
const delimiter = RocStr.init(testing.allocator, delimiterArr, delimiterArr.len);
|
||||
|
||||
defer {
|
||||
str.deinit(testing.allocator);
|
||||
delimiter.deinit(testing.allocator);
|
||||
}
|
||||
|
||||
const segmentsCount = countSegments(str, delimiter);
|
||||
|
||||
expectEqual(segmentsCount, 2);
|
||||
|
@ -499,6 +556,11 @@ test "countSegments: delimiter interspered" {
|
|||
const delimiterArr = "!";
|
||||
const delimiter = RocStr.init(testing.allocator, delimiterArr, delimiterArr.len);
|
||||
|
||||
defer {
|
||||
str.deinit(testing.allocator);
|
||||
delimiter.deinit(testing.allocator);
|
||||
}
|
||||
|
||||
const segmentsCount = countSegments(str, delimiter);
|
||||
|
||||
expectEqual(segmentsCount, 3);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue