From 6c9db58c76b31424276cb70595c5208aa6c015ae Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Wed, 6 Mar 2019 18:37:20 -0700 Subject: Add ListBuilder.Len() This commit adds a method to check the current length of a list on a `ListBuilder`. This allows the length to be checked without marking the next builder change as immutable. --- immutable_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'immutable_test.go') diff --git a/immutable_test.go b/immutable_test.go index 9c3f548..c6dfc13 100644 --- a/immutable_test.go +++ b/immutable_test.go @@ -274,7 +274,9 @@ func (l *TList) Slice(start, end int) { // Validate returns an error if the slice and List are different. func (l *TList) Validate() error { - if got, exp := len(l.std), l.im.Len(); got != exp { + if got, exp := l.im.Len(), len(l.std); got != exp { + return fmt.Errorf("Len()=%v, expected %d", got, exp) + } else if got, exp := l.builder.Len(), len(l.std); got != exp { return fmt.Errorf("Len()=%v, expected %d", got, exp) } -- cgit v1.2.3