github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/examples/gno.land/p/demo/bf/bf_test.gno (about)

     1  package bf
     2  
     3  import (
     4  	"bytes"
     5  	"testing"
     6  )
     7  
     8  func TestExecuteBrainfuck(t *testing.T) {
     9  	testCases := []struct {
    10  		name     string
    11  		code     string
    12  		expected string
    13  	}{
    14  		{
    15  			name:     "hello",
    16  			code:     "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.",
    17  			expected: "Hello World",
    18  		},
    19  		{
    20  			name:     "increment",
    21  			code:     "+++++ +++++ [ > +++++ ++ < - ] > +++++ .",
    22  			expected: "K",
    23  		},
    24  		// Add more test cases as needed
    25  	}
    26  
    27  	for _, tc := range testCases {
    28  		t.Run(tc.name, func(t *testing.T) {
    29  			result := Execute(tc.code)
    30  			if result != tc.expected {
    31  				t.Errorf("Expected output: %s, but got: %s", tc.expected, result)
    32  			}
    33  		})
    34  	}
    35  }