Skip to content

Commit 2fa73d4

Browse files
Sync custom-set tests (#245)
1 parent 6535fce commit 2fa73d4

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

exercises/practice/custom-set/.meta/tests.toml

+6
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ description = "Sets with the same elements are equal -> sets with different elem
7575
[06059caf-9bf4-425e-aaff-88966cb3ea14]
7676
description = "Sets with the same elements are equal -> set is not equal to larger set with same elements"
7777

78+
[d4a1142f-09aa-4df9-8b83-4437dcf7ec24]
79+
description = "Sets with the same elements are equal -> set is equal to a set constructed from an array with duplicates"
80+
7881
[8a677c3c-a658-4d39-bb88-5b5b1a9659f4]
7982
description = "Unique elements can be added to a set -> add to empty set"
8083

@@ -111,6 +114,9 @@ description = "Difference (or Complement) of a set is a set of all elements that
111114
[c5ac673e-d707-4db5-8d69-7082c3a5437e]
112115
description = "Difference (or Complement) of a set is a set of all elements that are only in the first set -> difference of two non-empty sets is a set of elements that are only in the first set"
113116

117+
[20d0a38f-7bb7-4c4a-ac15-90c7392ecf2b]
118+
description = "Difference (or Complement) of a set is a set of all elements that are only in the first set -> difference removes all duplicates in the first set"
119+
114120
[c45aed16-5494-455a-9033-5d4c93589dc6]
115121
description = "Union returns a set of all elements in either set -> union of empty sets is an empty set"
116122

exercises/practice/custom-set/run_test.v

+15
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ fn test_set_is_not_equal_to_larger_set_with_same_elements() {
134134
assert !a_set.equal(b_set)
135135
}
136136

137+
fn test_set_is_equal_to_a_set_constructed_from_an_array_with_duplicates() {
138+
a_set := CustomSet.new([1])
139+
b_set := CustomSet.new([1, 1])
140+
141+
assert a_set.equal(b_set)
142+
}
143+
137144
// add
138145

139146
fn test_add_to_empty_set() {
@@ -228,6 +235,14 @@ fn test_difference_of_two_non_empty_sets_is_a_set_of_elements_that_are_only_in_t
228235
assert a_set.difference(b_set).equal(expected)
229236
}
230237

238+
fn test_difference_removes_all_duplicates_in_the_first_set() {
239+
a_set := CustomSet.new([1, 1])
240+
b_set := CustomSet.new([1])
241+
expected := CustomSet.new([]int{})
242+
243+
assert a_set.difference(b_set).equal(expected)
244+
}
245+
231246
// @union
232247

233248
fn test_union_of_empty_sets_is_an_empty_set() {

0 commit comments

Comments
 (0)