dawn-cmake/tools/src/cts/result/status_test.go
Ben Clayton 2363ad16ea tools/src/cts/result: Add more helpers
Add result.List.StatusTree() for building a query.Tree[Status].
Add helpers for serializing results.
Add helpers for merging and de-duplicating results.

Change the interface of result.List.ReplaceDuplicates() so that the
merging function takes a status set instead of a list of results.

Bug: dawn:1342
Change-Id: I77580ec5fd4c8f12109fb6e9e83afea8b740260c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87240
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-04-20 19:10:42 +00:00

55 lines
1.4 KiB
Go

// Copyright 2022 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package result_test
import (
"testing"
"dawn.googlesource.com/dawn/tools/src/cts/result"
"github.com/google/go-cmp/cmp"
)
func TestCommonStatus(t *testing.T) {
pass := result.Pass
type Test struct {
in []result.Status
expect *result.Status
}
for _, test := range []Test{
{
in: nil,
expect: nil,
}, {
in: []result.Status{},
expect: nil,
}, {
in: []result.Status{result.Pass},
expect: &pass,
}, {
in: []result.Status{result.Pass, result.Pass, result.Pass},
expect: &pass,
}, {
in: []result.Status{result.Pass, result.Failure, result.Pass},
expect: nil,
},
} {
got := result.CommonStatus(test.in)
if diff := cmp.Diff(got, test.expect); diff != "" {
t.Errorf("%v.CommonStatus('%v') was not as expected:\n%v", test.in, test.expect, diff)
}
}
}