blob: 6fec9b34dd1cb3358bceadc5cf056ff387b1ec1b [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file was auto-generated via go generate.
// DO NOT UPDATE MANUALLY
package set
import (
"testing"
)
func TestString(t *testing.T) {
slice := []string{}
slice = append(slice, "a")
slice = append(slice, "b")
// Test conversion from a slice.
s1 := String.FromSlice(slice)
for i, want := range []bool{true, true} {
if _, got := s1[slice[i]]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(s1), len(slice); got != want {
t.Errorf("got %v, want %v", got, want)
}
// Test conversion to a slice.
slice2 := String.ToSlice(s1)
for i, got := range []bool{true, true} {
if _, want := s1[(slice2[i])]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(slice2), len(s1); got != want {
t.Errorf("got %v, want %v", got, want)
}
// Test set difference.
{
s1 := String.FromSlice(slice)
s2 := String.FromSlice(slice[1:])
String.Difference(s1, s2)
for i, want := range []bool{true, false} {
if _, got := s1[(slice[i])]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(s1), 1; got != want {
t.Errorf("got %v, want %v", got, want)
}
s3 := String.FromSlice(slice[1:])
s4 := String.FromSlice(slice)
String.Difference(s3, s4)
for i, want := range []bool{false, false} {
if _, got := s3[(slice[i])]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(s3), 0; got != want {
t.Errorf("got %v, want %v", got, want)
}
s5 := String.FromSlice(slice[1:])
s6 := String.FromSlice(slice[:1])
String.Difference(s5, s6)
for i, want := range []bool{false, true} {
if _, got := s5[(slice[i])]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(s5), 1; got != want {
t.Errorf("got %v, want %v", got, want)
}
s7 := String.FromSlice(slice)
s8 := String.FromSlice(slice)
String.Difference(s7, s8)
for i, want := range []bool{false, false} {
if _, got := s7[(slice[i])]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(s7), 0; got != want {
t.Errorf("got %v, want %v", got, want)
}
}
// Test set intersection.
{
s1 := String.FromSlice(slice)
s2 := String.FromSlice(slice[1:])
String.Intersection(s1, s2)
for i, want := range []bool{false, true} {
if _, got := s1[(slice[i])]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(s1), 1; got != want {
t.Errorf("got %v, want %v", got, want)
}
s3 := String.FromSlice(slice[1:])
s4 := String.FromSlice(slice)
String.Intersection(s3, s4)
for i, want := range []bool{false, true} {
if _, got := s3[(slice[i])]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(s3), 1; got != want {
t.Errorf("got %v, want %v", got, want)
}
s5 := String.FromSlice(slice[1:])
s6 := String.FromSlice(slice[:1])
String.Intersection(s5, s6)
for i, want := range []bool{false, false} {
if _, got := s5[(slice[i])]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(s5), 0; got != want {
t.Errorf("got %v, want %v", got, want)
}
s7 := String.FromSlice(slice)
s8 := String.FromSlice(slice)
String.Intersection(s7, s8)
for i, want := range []bool{true, true} {
if _, got := s7[(slice[i])]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(s7), 2; got != want {
t.Errorf("got %v, want %v", got, want)
}
}
// Test set union.
{
s1 := String.FromSlice(slice[:1])
s2 := String.FromSlice(slice[1:])
String.Union(s1, s2)
for i, want := range []bool{true, true} {
if _, got := s1[(slice[i])]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(s1), 2; got != want {
t.Errorf("got %v, want %v", got, want)
}
s3 := String.FromSlice(slice[1:])
s4 := String.FromSlice(slice)
String.Union(s3, s4)
for i, want := range []bool{true, true} {
if _, got := s3[(slice[i])]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(s3), 2; got != want {
t.Errorf("got %v, want %v", got, want)
}
s5 := String.FromSlice(slice[1:])
s6 := String.FromSlice(slice[:1])
String.Union(s5, s6)
for i, want := range []bool{true, true} {
if _, got := s5[(slice[i])]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(s5), 2; got != want {
t.Errorf("got %v, want %v", got, want)
}
s7 := String.FromSlice(slice)
s8 := String.FromSlice(slice)
String.Union(s7, s8)
for i, want := range []bool{true, true} {
if _, got := s7[(slice[i])]; got != want {
t.Errorf("index %d: got %v, want %v", i, got, want)
}
}
if got, want := len(s7), 2; got != want {
t.Errorf("got %v, want %v", got, want)
}
}
}