<commit_before>// Copyright 2014 The sutil Author. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.


package stext

import (
	"testing"
	"github.com/shawnfeng/sutil/slog"
)


func ck(t *testing.T, correct, format string, params ...string) {

	res := LocationText(format, params...)
	slog.Infoln(format, params, res)

	if res != correct {
		t.Errorf("correct:%s format:%s params:%s res:%s", correct, format, params, res)
	}
}

func TestLocText(t *testing.T) {

	// 放在开头
	ck(t, "123abc", "%@abc", "123")



	// 放在末尾
	ck(t, "世界你好abc123", "世界你好abc%@", "123")


	// %%
	ck(t, "abc%@", "abc%%@", "123")


	// %% 混合
	ck(t, "abc%@123", "abc%%@%@", "123")

	// 多参数
	ck(t, "456abc%@123", "%@abc%%@%@", "456", "123")


	// 多余参数
	ck(t, "456abc%@123", "%@abc%%@%@%@%@%@", "456", "123")

	// 指定位置参数
	ck(t, "123abc%@456123", "%2@abc%%@%@%@%@%@", "456", "123")<commit_msg>add loc test<commit_after>// Copyright 2014 The sutil Author. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.


package stext

import (
	"testing"
	"github.com/shawnfeng/sutil/slog"
)


func ck(t *testing.T, correct, format string, params ...string) {

	res := LocationText(format, params...)
	slog.Infoln(format, params, res)

	if res != correct {
		t.Errorf("correct:%s format:%s params:%s res:%s", correct, format, params, res)
	}
}

func TestLocText(t *testing.T) {
	// 空测试
	ck(t, "", "", "123")
	ck(t, "123", "%@", "123")
	ck(t, "123", "%@%@", "123")
	ck(t, "123%@", "%@%%@", "123")
	ck(t, "123%a@@", "%@%a@@", "123")

	ck(t, "%abc", "%@%abc")
	ck(t, "123%abc", "%@%abc", "123")

	// 放在开头
	ck(t, "123abc", "%@abc", "123")



	// 放在末尾
	ck(t, "世界你好abc123", "世界你好abc%@", "123")


	// %%
	ck(t, "abc%@", "abc%%@", "123")


	// %% 混合
	ck(t, "abc%@123", "abc%%@%@", "123")

	// 多参数
	ck(t, "456abc%@123", "%@abc%%@%@", "456", "123")


	// 多余参数
	ck(t, "456abc%@123", "%@abc%%@%@%@%@%@", "456", "123")

	// 指定位置参数
	ck(t, "123abc%@456123", "%2@abc%%@%@%@%@%@", "456", "123")
{'fraction_non_alphanumeric': 0.27465127465127465, 'fraction_numerical': 0.0784030784030784, 'mean_word_length': 3.759725400457666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6848959', 'n_tokens_mistral': 1099, 'n_tokens_neox': 961, 'n_words': 220}