File: gemini_test.go

package info (click to toggle)
golang-github-makeworld-the-better-one-go-gemini 0.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 128 kB
  • sloc: makefile: 3
file content (35 lines) | stat: -rw-r--r-- 723 bytes parent folder | download | duplicates (3)
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
package gemini

import "testing"

func TestSimplifyStatus(t *testing.T) {
	tests := []struct {
		ComplexStatus int
		SimpleStatus  int
	}{
		{10, 10},
		{20, 20},
		{21, 20},
		{44, 40},
		{59, 50},
	}

	for _, tt := range tests {
		result := SimplifyStatus(tt.ComplexStatus)
		if result != tt.SimpleStatus {
			t.Errorf("Expected the simplified status of %d to be %d, got %d instead", tt.ComplexStatus, tt.SimpleStatus, result)
		}
	}
}

func TestQuery(t *testing.T) {
	query := `t/&^*% es\++\t`
	escaped := `t%2F&%5E%2A%25%20es%5C%2B%2B%5Ct`
	if QueryEscape(query) != escaped {
		t.Errorf("Query escape failed")
	}
	q, err := QueryUnescape(escaped)
	if q != query || err != nil {
		t.Errorf("Query unescape failed")
	}
}