File size: 5,858 Bytes
5a55e77
 
 
 
 
 
 
 
cbe30d3
 
5a55e77
 
 
 
 
 
cbe30d3
 
 
 
 
 
 
 
 
 
5a55e77
 
cbe30d3
5a55e77
 
 
 
 
 
 
 
 
 
 
 
cbe30d3
5a55e77
 
 
 
 
 
 
 
 
 
 
 
cbe30d3
5a55e77
 
 
 
 
 
 
 
 
 
 
 
cbe30d3
5a55e77
 
 
 
 
 
 
 
 
 
 
 
cbe30d3
5a55e77
 
 
 
 
 
 
 
 
 
 
 
cbe30d3
5a55e77
 
 
 
 
 
 
 
 
 
 
 
cbe30d3
5a55e77
 
 
 
 
 
 
 
 
cbe30d3
5a55e77
 
 
 
 
 
 
cbe30d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5a55e77
 
 
 
cbe30d3
5a55e77
cbe30d3
5a55e77
cbe30d3
 
5a55e77
 
 
 
 
 
 
 
 
 
cbe30d3
5a55e77
cbe30d3
5a55e77
 
 
 
 
 
 
 
 
cbe30d3
5a55e77
 
cbe30d3
 
5a55e77
cbe30d3
 
5a55e77
 
 
 
cbe30d3
 
5a55e77
cbe30d3
 
5a55e77
 
 
cbe30d3
5a55e77
 
cbe30d3
5a55e77
cbe30d3
5a55e77
 
 
 
 
 
 
 
 
 
cbe30d3
5a55e77
 
 
cbe30d3
 
 
 
5a55e77
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
package model

import "testing"

// ===== ParseModelName =====

func TestParseModelName_Plain(t *testing.T) {
	base, thinking, search, tools := ParseModelName("GLM-4.7")
	if base != "glm-4.7" {
		t.Errorf("base = %q, want %q", base, "glm-4.7")
	}
	if thinking || search || tools {
		t.Errorf("flags = (%v, %v, %v), want all false", thinking, search, tools)
	}
}

func TestParseModelName_Lowercase(t *testing.T) {
	base, thinking, _, _ := ParseModelName("glm-4.7-thinking")
	if base != "glm-4.7" {
		t.Errorf("base = %q, want %q", base, "glm-4.7")
	}
	if !thinking {
		t.Error("thinking should be true")
	}
}

func TestParseModelName_Thinking(t *testing.T) {
	base, thinking, search, tools := ParseModelName("GLM-4.7-thinking")
	if base != "glm-4.7" {
		t.Errorf("base = %q", base)
	}
	if !thinking {
		t.Error("thinking should be true")
	}
	if search || tools {
		t.Error("search and tools should be false")
	}
}

func TestParseModelName_Search(t *testing.T) {
	base, thinking, search, tools := ParseModelName("GLM-4.7-search")
	if base != "glm-4.7" {
		t.Errorf("base = %q", base)
	}
	if !search {
		t.Error("search should be true")
	}
	if thinking || tools {
		t.Error("thinking and tools should be false")
	}
}

func TestParseModelName_Tools(t *testing.T) {
	base, thinking, search, tools := ParseModelName("GLM-4.7-tools")
	if base != "glm-4.7" {
		t.Errorf("base = %q", base)
	}
	if !tools {
		t.Error("tools should be true")
	}
	if thinking || search {
		t.Error("thinking and search should be false")
	}
}

func TestParseModelName_ThinkingSearch(t *testing.T) {
	base, thinking, search, tools := ParseModelName("GLM-4.7-thinking-search")
	if base != "glm-4.7" {
		t.Errorf("base = %q", base)
	}
	if !thinking || !search {
		t.Error("thinking and search should both be true")
	}
	if tools {
		t.Error("tools should be false")
	}
}

func TestParseModelName_ToolsThinking(t *testing.T) {
	base, thinking, search, tools := ParseModelName("GLM-4.7-tools-thinking")
	if base != "glm-4.7" {
		t.Errorf("base = %q", base)
	}
	if !tools || !thinking {
		t.Error("tools and thinking should both be true")
	}
	if search {
		t.Error("search should be false")
	}
}

func TestParseModelName_ToolsSearch(t *testing.T) {
	base, thinking, search, tools := ParseModelName("GLM-4.7-tools-search")
	if base != "glm-4.7" {
		t.Errorf("base = %q", base)
	}
	if !tools || !search {
		t.Error("tools and search should both be true")
	}
	if thinking {
		t.Error("thinking should be false")
	}
}

func TestParseModelName_AllTags(t *testing.T) {
	base, thinking, search, tools := ParseModelName("GLM-4.7-tools-thinking-search")
	if base != "glm-4.7" {
		t.Errorf("base = %q", base)
	}
	if !thinking || !search || !tools {
		t.Errorf("all flags should be true, got (%v, %v, %v)", thinking, search, tools)
	}
}

func TestParseModelName_ReverseOrder(t *testing.T) {
	base, thinking, search, tools := ParseModelName("GLM-4.7-search-thinking-tools")
	if base != "glm-4.7" {
		t.Errorf("base = %q", base)
	}
	if !thinking || !search || !tools {
		t.Errorf("all flags should be true, got (%v, %v, %v)", thinking, search, tools)
	}
}

// ===== GLM-5 =====

func TestParseModelName_GLM5(t *testing.T) {
	base, thinking, _, _ := ParseModelName("glm-5")
	if base != "glm-5" {
		t.Errorf("base = %q, want %q", base, "glm-5")
	}
	if thinking {
		t.Error("thinking should be false")
	}
}

func TestGetTargetModel_GLM5(t *testing.T) {
	target := GetTargetModel("glm-5")
	if target != "glm-5" {
		t.Errorf("GetTargetModel(glm-5) = %q, want %q", target, "glm-5")
	}
}

func TestGetTargetModel_GLM5Thinking(t *testing.T) {
	target := GetTargetModel("glm-5-thinking")
	if target != "glm-5" {
		t.Errorf("GetTargetModel(glm-5-thinking) = %q, want %q", target, "glm-5")
	}
}

// ===== IsToolsModel =====

func TestIsToolsModel_True(t *testing.T) {
	tests := []string{
		"glm-4.7-tools",
		"GLM-4.7-tools-thinking",
		"glm-4.7-tools-search",
		"GLM-4.7-thinking-tools",
		"glm-4.5-tools",
		"glm-5-tools",
	}
	for _, m := range tests {
		if !IsToolsModel(m) {
			t.Errorf("IsToolsModel(%q) = false, want true", m)
		}
	}
}

func TestIsToolsModel_False(t *testing.T) {
	tests := []string{
		"glm-4.7",
		"GLM-4.7-thinking",
		"glm-4.7-search",
		"GLM-4.7-thinking-search",
	}
	for _, m := range tests {
		if IsToolsModel(m) {
			t.Errorf("IsToolsModel(%q) = true, want false", m)
		}
	}
}

// ===== IsThinkingModel / IsSearchModel =====

func TestIsThinkingModel_WithTools(t *testing.T) {
	if !IsThinkingModel("glm-4.7-tools-thinking") {
		t.Error("IsThinkingModel should be true for glm-4.7-tools-thinking")
	}
	if IsThinkingModel("glm-4.7-tools") {
		t.Error("IsThinkingModel should be false for glm-4.7-tools")
	}
}

func TestIsSearchModel_WithTools(t *testing.T) {
	if !IsSearchModel("glm-4.7-tools-search") {
		t.Error("IsSearchModel should be true for glm-4.7-tools-search")
	}
	if IsSearchModel("glm-4.7-tools") {
		t.Error("IsSearchModel should be false for glm-4.7-tools")
	}
}

// ===== GetTargetModel =====

func TestGetTargetModel_WithTools(t *testing.T) {
	target := GetTargetModel("glm-4.7-tools")
	if target != "glm-4.7" {
		t.Errorf("GetTargetModel(glm-4.7-tools) = %q, want %q", target, "glm-4.7")
	}
}

func TestGetTargetModel_WithToolsThinking(t *testing.T) {
	target := GetTargetModel("GLM-4.7-tools-thinking")
	if target != "glm-4.7" {
		t.Errorf("GetTargetModel(GLM-4.7-tools-thinking) = %q, want %q", target, "glm-4.7")
	}
}

// ===== ModelList =====

func TestModelList_ContainsToolsVariants(t *testing.T) {
	expected := map[string]bool{
		"glm-4.7-tools":          false,
		"glm-4.7-tools-thinking": false,
		"glm-5":                  false,
		"glm-5-tools":            false,
	}

	for _, m := range ModelList {
		if _, ok := expected[m]; ok {
			expected[m] = true
		}
	}

	for name, found := range expected {
		if !found {
			t.Errorf("ModelList missing %q", name)
		}
	}
}