// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.

// t_builtin-string_test.go
package expr

import (
	"testing"
)

func TestFuncString(t *testing.T) {
	section := "Builtin-String"

	inputs := []inputType{
		/*   1 */ {`builtin "string"; strJoin("-", "one", "two", "three")`, "one-two-three", nil},
		/*   2 */ {`builtin "string"; strJoin("-", ["one", "two", "three"])`, "one-two-three", nil},
		/*   3 */ {`builtin "string"; ls= ["one", "two", "three"]; strJoin("-", ls)`, "one-two-three", nil},
		/*   4 */ {`builtin "string"; ls= ["one", "two", "three"]; strJoin(1, ls)`, nil, `strJoin(): the "separator" parameter must be a string, got a integer (1)`},
		/*   5 */ {`builtin "string"; ls= ["one", 2, "three"]; strJoin("-", ls)`, nil, `strJoin(): expected string, got integer (2)`},
		/*   6 */ {`builtin "string"; "<"+strTrim("  bye bye  ")+">"`, "<bye bye>", nil},
		/*   7 */ {`builtin "string"; strSub("0123456789", 1,2)`, "12", nil},
		/*   8 */ {`builtin "string"; strSub("0123456789", -3,2)`, "78", nil},
		/*   9 */ {`builtin "string"; strSub("0123456789", -3)`, "789", nil},
		/*  10 */ {`builtin "string"; strSub("0123456789")`, "0123456789", nil},
		/*  11 */ {`builtin "string"; strStartsWith("0123456789", "xyz", "012")`, true, nil},
		/*  12 */ {`builtin "string"; strStartsWith("0123456789", "xyz", "0125")`, false, nil},
		/*  13 */ {`builtin "string"; strStartsWith("0123456789")`, nil, `strStartsWith(): too few params -- expected 2 or more, got 1`},
		/*  14 */ {`builtin "string"; strEndsWith("0123456789", "xyz", "789")`, true, nil},
		/*  15 */ {`builtin "string"; strEndsWith("0123456789", "xyz", "0125")`, false, nil},
		/*  16 */ {`builtin "string"; strEndsWith("0123456789")`, nil, `strEndsWith(): too few params -- expected 2 or more, got 1`},
		/*  17 */ {`builtin "string"; strSplit("one-two-three", "-")`, newListA("one", "two", "three"), nil},
		/*  18 */ {`builtin "string"; strJoin("-", [1, "two", "three"])`, nil, `strJoin(): expected string, got integer (1)`},
		/*  19 */ {`builtin "string"; strJoin()`, nil, `strJoin(): too few params -- expected 1 or more, got 0`},

		/*  69 */ /*{`builtin "string"; $$global`, `vars: {
		}
		funcs: {
		    	add(any=0 ...) -> number,
		    	dec(any) -> decimal,
		    	endsWithStr(source, suffix) -> boolean,
		    	fract(any, denominator=1) -> fraction,
		    	import( ...) -> any,
		    	importAll( ...) -> any,
		    	int(any) -> integer,
		    	isBool(any) -> boolean,
		    	isDec(any) -> boolean,
		    	isDict(any) -> boolean,
		    	isFloat(any) -> boolean,
		    	isFract(any) -> boolean,
		    	isInt(any) -> boolean,
		    	isList(any) -> boolean,
		    	isNil(any) -> boolean,
		    	isString(any) -> boolean,
		    	joinStr(separator, item="" ...) -> string,
		    	mul(any=1 ...) -> number,
		    	splitStr(source, separator="", count=-1) -> list of string,
		    	startsWithStr(source, prefix) -> boolean,
		    	subStr(source, start=0, count=-1) -> string,
		    	trimStr(source) -> string
		}
		`, nil},*/
	}

	//t.Setenv("EXPR_PATH", ".")

	// runTestSuiteSpec(t, section, inputs, 19)
	runTestSuite(t, section, inputs)
}