package iskra import "testing" func TestBranchRotation(t *testing.T) { if BranchRotation(BranchType, BranchFunc) != RotRight { t.Fatal("Type->Func should be Right") } if BranchRotation(BranchFunc, BranchData) != RotRight { t.Fatal("Func->Data should be Right") } if BranchRotation(BranchData, BranchType) != RotRight { t.Fatal("Data->Type should be Right") } if BranchRotation(BranchFunc, BranchType) != RotLeft { t.Fatal("Func->Type should be Left") } if BranchRotation(BranchType, BranchType) != RotStay { t.Fatal("Type->Type should be Stay") } } func TestBranchRotationInvalid(t *testing.T) { if BranchRotation(0, BranchType) != RotUnknown { t.Fatal("invalid from should be Unknown") } if BranchRotation(BranchType, 0) != RotUnknown { t.Fatal("invalid to should be Unknown") } } func TestRotationString(t *testing.T) { if RotRight.String() != "right" { t.Fatal("wrong string for RotRight") } if RotBlockOpen.String() != "{" { t.Fatal("wrong string for RotBlockOpen") } } func TestRotationIsStructural(t *testing.T) { if RotRight.IsStructural() { t.Fatal("RotRight should not be structural") } if !RotBlockOpen.IsStructural() { t.Fatal("RotBlockOpen should be structural") } if !RotSeparator.IsStructural() { t.Fatal("RotSeparator should be structural") } } func TestRotationRoundtrip(t *testing.T) { var m MetaEntry m.SetRotation(RotLeft) if m.GetRotation() != RotLeft { t.Fatal("rotation round-trip failed") } } func TestBigramTransition(t *testing.T) { var m MetaEntry path := MakeTritPath(BranchFunc, SubControl) m.SetBigramTransition(RotRight, path) rot, got := m.GetBigramTransition() if rot != RotRight { t.Fatal("wrong rotation") } if got != path { t.Fatal("wrong target path") } }