github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/tools/syz-imagegen/combinations_test.go (about)

     1  // Copyright 2025 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package main
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  )
    11  
    12  func TestFullCombinations(t *testing.T) {
    13  	t.Run("empty", func(t *testing.T) {
    14  		assert.Len(t, CoveringArray([][]string{}, 0), 0)
    15  	})
    16  	t.Run("single", func(t *testing.T) {
    17  		assert.Equal(t, [][]string{
    18  			{"A", "B", "C"},
    19  		}, CoveringArray([][]string{
    20  			{"A"},
    21  			{"B"},
    22  			{"C"},
    23  		}, 0))
    24  	})
    25  	t.Run("binary", func(t *testing.T) {
    26  		assert.Equal(t, [][]string{
    27  			{"A", "B", "C"},
    28  			{"A", "B", "c"},
    29  			{"A", "b", "C"},
    30  			{"A", "b", "c"},
    31  			{"a", "B", "C"},
    32  			{"a", "B", "c"},
    33  			{"a", "b", "C"},
    34  			{"a", "b", "c"},
    35  		}, CoveringArray([][]string{
    36  			{"A", "a"},
    37  			{"B", "b"},
    38  			{"C", "c"},
    39  		}, 0))
    40  	})
    41  }
    42  
    43  func TestPairCombinations(t *testing.T) {
    44  	// Theoretically, there may be multiple correct answers.
    45  	// For now, let's keep the current algorithm's output so that if the code behavior changes unexpectedly,
    46  	// we'd notice.
    47  	assert.Equal(t, [][]string{
    48  		{"A", "B", "C"},
    49  		{"A", "b", "c"},
    50  		{"a", "B", "c"},
    51  		{"a", "b", "C"},
    52  	}, CoveringArray([][]string{
    53  		{"A", "a"},
    54  		{"B", "b"},
    55  		{"C", "c"},
    56  	}, 4))
    57  }