File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,13 @@ func (s *set) Length() (int) {
2121 return len (s .data )
2222}
2323
24+ func (s * set ) Values () (values []string ) {
25+ for val , _ := range s .data {
26+ values = append (values , val )
27+ }
28+ return
29+ }
30+
2431func newSet () (* set ) {
2532 return & set {make (map [string ] bool )}
2633}
Original file line number Diff line number Diff line change @@ -18,9 +18,22 @@ func TestBasicSetActions(t *testing.T) {
1818 t .Fatal ("set should contain 'foo'" )
1919 }
2020
21+ v := s .Values ()
22+ if len (v ) != 1 {
23+ t .Fatal ("set.Values did not report correct number of values" )
24+ }
25+ if v [0 ] != "foo" {
26+ t .Fatal ("set.Values did not report value" )
27+ }
28+
2129 s .Remove ("foo" )
2230
2331 if s .Contains ("foo" ) {
2432 t .Fatal ("set should not contain 'foo'" )
2533 }
34+
35+ v = s .Values ()
36+ if len (v ) != 0 {
37+ t .Fatal ("set.Values did not report correct number of values" )
38+ }
2639}
You can’t perform that action at this time.
0 commit comments