blob: cd3d056812487451e9e968ebfa6a309a3e22e9c2 [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 TestInt32Bool(t *testing.T) {
slice := []int32{}
slice = append(slice, -1)
slice = append(slice, 1)
// Test conversion from a slice.
s1 := Int32Bool.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 := Int32Bool.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 := Int32Bool.FromSlice(slice)
s2 := Int32Bool.FromSlice(slice[1:])
Int32Bool.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 := Int32Bool.FromSlice(slice[1:])
s4 := Int32Bool.FromSlice(slice)
Int32Bool.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 := Int32Bool.FromSlice(slice[1:])
s6 := Int32Bool.FromSlice(slice[:1])
Int32Bool.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 := Int32Bool.FromSlice(slice)
s8 := Int32Bool.FromSlice(slice)
Int32Bool.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 := Int32Bool.FromSlice(slice)
s2 := Int32Bool.FromSlice(slice[1:])
Int32Bool.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 := Int32Bool.FromSlice(slice[1:])
s4 := Int32Bool.FromSlice(slice)
Int32Bool.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 := Int32Bool.FromSlice(slice[1:])
s6 := Int32Bool.FromSlice(slice[:1])
Int32Bool.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 := Int32Bool.FromSlice(slice)
s8 := Int32Bool.FromSlice(slice)
Int32Bool.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 := Int32Bool.FromSlice(slice[:1])
s2 := Int32Bool.FromSlice(slice[1:])
Int32Bool.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 := Int32Bool.FromSlice(slice[1:])
s4 := Int32Bool.FromSlice(slice)
Int32Bool.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 := Int32Bool.FromSlice(slice[1:])
s6 := Int32Bool.FromSlice(slice[:1])
Int32Bool.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 := Int32Bool.FromSlice(slice)
s8 := Int32Bool.FromSlice(slice)
Int32Bool.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)
}
}
}