package diff
import (
bits "0dev.org/bits"
"fmt"
"testing"
)
type diffSlice struct {
first []rune
second []rune
}
func (d diffSlice) Len() (int, int) {
return len(d.first), len(d.second)
}
func (d diffSlice) Equal(i, j int) bool {
return d.first[i] == d.second[j]
}
func TestLCS(t *testing.T) {
fmt.Println("")
data := diffSlice{
[]rune("abcdefgh"),
[]rune("abbcedfh"),
}
fmt.Println(Diff(data))
// first, second, total := LCS(data)
// fmt.Println(first, second, total)
}
func TestWTF(t *testing.T) {
data := diffSlice{
[]rune("abcdefgh"),
[]rune("abbcedfh"),
}
var len1, len2 int = data.Len()
var mat matrix = matrix{v: bits.NewBool(uint(len1 * len2)), lenX: len1, lenY: len2}
for i := 0; i < len1; i++ {
for j := 0; j < len2; j++ {
mat.v.Poke(mat.at(i, j), data.Equal(i, j))
}
}
debugPrint(box{5, 5, 6, 6}, mat)
debugPrint(box{5, 5, 7, 7}, mat)
debugPrint(box{5, 5, 8, 8}, mat)
}
func debugPrint(bounds box, mat matrix) {
// Debug print
fmt.Printf("-%d-%d--%d-%d--\n", bounds.x, bounds.y, bounds.lenX, bounds.lenY)
for i := bounds.x; i < bounds.lenX; i++ {
fmt.Print("| ")
for j := bounds.y; j < bounds.lenY; j++ {
//if vector.Peek(uint(j + (i * bounds.lenY))) {
if mat.v.Peek(mat.at(i, j)) {
fmt.Print("\\")
} else {
fmt.Print(".")
}
}
fmt.Println(" |")
}
fmt.Println("------------")
}