File: probs_test.go

package info (click to toggle)
golang-github-ulikunitz-xz 0.5.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,496 kB
  • sloc: makefile: 7; sh: 5
file content (37 lines) | stat: -rw-r--r-- 760 bytes parent folder | download
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
// Copyright 2014-2022 Ulrich Kunitz. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package randtxt

import (
	"bufio"
	"io"
	"math/rand"
	"testing"
)

func TestReader(t *testing.T) {
	lr := io.LimitReader(NewReader(rand.NewSource(13)), 195)
	pretty := NewGroupReader(lr)
	scanner := bufio.NewScanner(pretty)
	for scanner.Scan() {
		t.Log(scanner.Text())
	}
	if err := scanner.Err(); err != nil {
		t.Fatalf("scanner error %s", err)
	}
}

func TestComap(t *testing.T) {
	prs := cmap["TH"]
	for _, p := range prs[3:6] {
		t.Logf("%v", p)
	}
	p := 0.2
	x := cmap.trigram("TH", p)
	if x != "THE" {
		t.Fatalf("cmap.trigram(%q, %.1f) returned %q; want %q",
			"TH", p, x, "THE")
	}
}