// TestAddError tests the DataFrame addError function
TestAddError tests the DataFrame addError function
// TestAddError tests the DataFrame addError function
func TestAddError(t *testing.T) {
	df, _ := NewDF(MaxErrors(2))
	testCases := []struct {
		msg       string
		expCount  int64
		expErrors int64
	}{
		{
			msg:       "test1",
			expCount:  1,
			expErrors: 1,
		},
		{
			msg:       "test2",
			expCount:  2,
			expErrors: 2,
		},
		{
			msg:       "test3",
			expCount:  3,
			expErrors: 2,
		},
		{
			msg:       "test4",
			expCount:  4,
			expErrors: 2,
		},
	}
	for i, tc := range testCases {
		df.addError(errors.New(tc.msg))
		if df.errCount != tc.expCount {
			t.Errorf(
				"test %d: adding %s should cause %d errors but there are: %d",
				i, tc.msg, tc.expCount, df.errCount)
		}
		if int64(len(df.errors)) != tc.expErrors {
			t.Errorf(
				"test %d: adding %s should cause %d errors in the slice"+
					" but there are: %d",
				i, tc.msg, tc.expErrors, len(df.errors))
		}
		if tc.expErrors == tc.expCount {
			if len(df.errors) == 0 {
				t.Errorf(
					"test %d: adding %s should have put something into"+
						" the errors slice but it's empty",
					i, tc.msg)
			} else if df.errors[len(df.errors)-1].Error() != tc.msg {
				t.Errorf(
					"test %d: adding %s should have made it the last"+
						" entry in the errors slice but it's '%s'",
					i, tc.msg, df.errors[len(df.errors)-1])
			}
		}
	}
}
func TestAddError ( t * testing . T ) { df , _ := NewDF ( MaxErrors ( 2 ) ) testCases := [ ] struct { msg string expCount int64 expErrors int64 } { { msg : " " , expCount : 1 , expErrors : 1 , } , { msg : " " , expCount : 2 , expErrors : 2 , } , { msg : " " , expCount : 3 , expErrors : 2 , } , { msg : " " , expCount : 4 , expErrors : 2 , } , } for i , tc := range testCases { df . addError ( errors . New ( tc . msg ) ) if df . errCount != tc . expCount { t . Errorf ( " " , i , tc . msg , tc . expCount , df . errCount ) } if int64 ( len ( df . errors ) ) != tc . expErrors { t . Errorf ( " " + " " , i , tc . msg , tc . expErrors , len ( df . errors ) ) } if tc . expErrors == tc . expCount { if len ( df . errors ) == 0 { t . Errorf ( " " + " " , i , tc . msg ) } else if df . errors [ len ( df . errors ) - 1 ] . Error ( ) != tc . msg { t . Errorf ( " " + " " , i , tc . msg , df . errors [ len ( df . errors ) - 1 ] ) } } } }
TestAddError tests the DataFrame addError function
TestAddError tests the DataFrame addError function