mirror of
https://github.com/garraflavatra/go-fmp.git
synced 2025-07-12 17:34:05 +00:00
Fix table test
This commit is contained in:
@ -1,6 +1,22 @@
|
|||||||
package fmp
|
package fmp
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"slices"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func slicesHaveSameElements[Type comparable](a, b []Type) bool {
|
||||||
|
if len(a) != len(b) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, av := range a {
|
||||||
|
found := slices.Contains(b, av)
|
||||||
|
if !found {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func TestOpenFile(t *testing.T) {
|
func TestOpenFile(t *testing.T) {
|
||||||
f, err := OpenFile("../files/Untitled.fmp12")
|
f, err := OpenFile("../files/Untitled.fmp12")
|
||||||
@ -29,16 +45,13 @@ func TestTables(t *testing.T) {
|
|||||||
}
|
}
|
||||||
tables := f.Tables()
|
tables := f.Tables()
|
||||||
|
|
||||||
expected := "Untitled, WayDomains, WayProcesses"
|
expectedNames := []string{"Untitled", "WayDomains", "WayProcesses"}
|
||||||
tablesString := ""
|
tableNames := []string{}
|
||||||
for i, table := range tables {
|
for _, table := range tables {
|
||||||
tablesString += table.Name
|
tableNames = append(tableNames, table.Name)
|
||||||
if i < len(tables)-1 {
|
|
||||||
tablesString += ", "
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if tablesString != expected {
|
if !slicesHaveSameElements(tableNames, expectedNames) {
|
||||||
t.Errorf("expected tables to be '%s', got '%s'", expected, tablesString)
|
t.Errorf("tables do not match")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user