initial commits

master
Charles Iliya Krempeaux 2021-11-07 00:56:21 -07:00
parent 997a5dc37a
commit 94e13d7ad0
3 changed files with 1358 additions and 0 deletions

31
compile.go 100644
View File

@ -0,0 +1,31 @@
package iid
const (
maxbitwidth = 64
)
const (
maskfirst = 0b0111111111111111111111111111111111111111000000000000000000000000
masksecond = 0b0000000000000000000000000000000000000000111111111111111111111111
)
const (
widthfirst = 40
widthsecond = maxbitwidth - widthfirst
)
func compile(first uint64, second uint64) uint64 {
var compiled uint64 = ((first << widthsecond) & maskfirst) | (second & masksecond)
return compiled
}
func decompile(value uint64) (uint64, uint64) {
var first uint64 = (value & maskfirst) >> widthsecond
var second uint64 = value & masksecond
return first, second
}

885
compile_test.go 100644
View File

@ -0,0 +1,885 @@
package iid
import (
"testing"
)
func TestCompile(t *testing.T) {
tests := []struct{
First uint64
Second uint64
Expected uint64
}{
{
// v
First: 0b0000000000000000000000000000000000000000000000000000000000000001,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000001000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000000000000000010,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000010000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000000000000000100,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000100000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000000000000001000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000001000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000000000000010000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000010000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000000000000100000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000100000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000000000001000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000001000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000000000010000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000010000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000000000100000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000100000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000000001000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000001000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000000010000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000010000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000000100000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000100000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000001000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000001000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000010000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000010000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000000100000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000100000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000001000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000001000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000010000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000010000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000000100000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000100000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000001000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000001000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000010000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000010000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000000100000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000100000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000001000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000001000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000010000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000010000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000000100000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000100000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000001000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000001000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000010000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000010000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000000100000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000100000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000001000000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000001000000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000010000000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000010000000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000000100000000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000100000000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000001000000000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000001000000000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000010000000000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000010000000000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000000100000000000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000100000000000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000001000000000000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000001000000000000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000010000000000000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000010000000000000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000000100000000000000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000100000000000000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000001000000000000000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0001000000000000000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000010000000000000000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0010000000000000000000000000000000000000000000000000000000000000,
// ^
},
{
// v
First: 0b0000000000000000000000000100000000000000000000000000000000000000,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0100000000000000000000000000000000000000000000000000000000000000,
// ^
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0100000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0010000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0001000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000100000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000010000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000001000000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000100000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000010000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000001000000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000100000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000010000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000001000000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000100000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000010000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000001000000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000100000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000010000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000001000000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000100000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000010000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000001000000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000100000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000010000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000001000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000100000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000010000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000001000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000100000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000010000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000001000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000100000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000010000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000001000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000100000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000010000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000001000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000100000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000010000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000001000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000100000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000100000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000010000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000010000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000001000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000001000000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000100000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000100000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000010000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000010000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000001000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000001000000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000100000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000100000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000010000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000010000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000001000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000001000000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000100000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000100000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000010000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000010000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000001000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000001000000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000000100000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000100000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000000010000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000010000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000000001000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000001000000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000000000100000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000100000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000000000010000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000010000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000000000001000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000001000000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000000000000100000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000100000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000000000000010000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000010000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000000000000001000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000001000,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000000000000000100,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000100,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000000000000000010,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000010,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v
Second: 0b0000000000000000000000000000000000000000000000000000000000000001,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000001,
},
{
// v v
First: 0b0000000000000000000000000100000000000000000000000000000000000001,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0100000000000000000000000000000000000001000000000000000000000000,
// ^ ^
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
// v v
Second: 0b0100000000000000000000001000000000000000000000000000000000000000,
Expected: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
// v v
First: 0b0000000000000000000000000100000000000000000000000000000000000001,
// v v
Second: 0b0000000000000000000000000000000000000000100000000000000000000001,
Expected: 0b0100000000000000000000000000000000000001100000000000000000000001,
// ^ ^^ ^
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111011111111111111111111111,
Expected: 0b0000000000000000000000000000000000000000011111111111111111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111101111111111111111111111,
Expected: 0b0000000000000000000000000000000000000000101111111111111111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111110111111111111111111111,
Expected: 0b0000000000000000000000000000000000000000110111111111111111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111011111111111111111111,
Expected: 0b0000000000000000000000000000000000000000111011111111111111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111101111111111111111111,
Expected: 0b0000000000000000000000000000000000000000111101111111111111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111110111111111111111111,
Expected: 0b0000000000000000000000000000000000000000111110111111111111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111011111111111111111,
Expected: 0b0000000000000000000000000000000000000000111111011111111111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111101111111111111111,
Expected: 0b0000000000000000000000000000000000000000111111101111111111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111110111111111111111,
Expected: 0b0000000000000000000000000000000000000000111111110111111111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111011111111111111,
Expected: 0b0000000000000000000000000000000000000000111111111011111111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111101111111111111,
Expected: 0b0000000000000000000000000000000000000000111111111101111111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111110111111111111,
Expected: 0b0000000000000000000000000000000000000000111111111110111111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111111011111111111,
Expected: 0b0000000000000000000000000000000000000000111111111111011111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111111101111111111,
Expected: 0b0000000000000000000000000000000000000000111111111111101111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111111110111111111,
Expected: 0b0000000000000000000000000000000000000000111111111111110111111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111111111011111111,
Expected: 0b0000000000000000000000000000000000000000111111111111111011111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111111111101111111,
Expected: 0b0000000000000000000000000000000000000000111111111111111101111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111111111110111111,
Expected: 0b0000000000000000000000000000000000000000111111111111111110111111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111111111111011111,
Expected: 0b0000000000000000000000000000000000000000111111111111111111011111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111111111111101111,
Expected: 0b0000000000000000000000000000000000000000111111111111111111101111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111111111111110111,
Expected: 0b0000000000000000000000000000000000000000111111111111111111110111,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111111111111111011,
Expected: 0b0000000000000000000000000000000000000000111111111111111111111011,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111111111111111101,
Expected: 0b0000000000000000000000000000000000000000111111111111111111111101,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111111111111111110,
Expected: 0b0000000000000000000000000000000000000000111111111111111111111110,
},
{
First: 0b0000000000000000000000000000000000000000000000000000000000000000,
Second: 0b0111111111111111111111111111111111111111111111111111111111111111,
Expected: 0b0000000000000000000000000000000000000000111111111111111111111111,
},
{
First: 0b0000000000000000000000000111111111111111111111111111111111111111,
Second: 0b0000000000000000000000000000000000000000000000000000000000000000,
Expected: 0b0111111111111111111111111111111111111111000000000000000000000000,
},
}
for testNumber, test := range tests {
var actual uint64 = compile(test.First, test.Second)
if expected := test.Expected; expected != actual {
t.Errorf("For test #%d, the actual compiled result if not what was expected.", testNumber)
t.Logf("FIRST: %064b", test.First)
t.Logf("SECOND: %064b", test.Second)
t.Logf("EXPECTED: %064b", expected)
t.Logf("ACTUAL: %064b", actual)
continue
}
}
}

442
decompile_test.go 100644
View File

@ -0,0 +1,442 @@
package iid
import (
"testing"
)
func TestDecompile(t *testing.T) {
tests := []struct{
Value uint64
}{
{
Value: 0b0000000000000000000000000000000000000000000000000000000000000000,
},
{
Value: 0b0000000000000000000000000000000000000000000000000000000000000001,
},
{
Value: 0b0000000000000000000000000000000000000000000000000000000000000010,
},
{
Value: 0b0000000000000000000000000000000000000000000000000000000000000100,
},
{
Value: 0b0000000000000000000000000000000000000000000000000000000000001000,
},
{
Value: 0b0000000000000000000000000000000000000000000000000000000000010000,
},
{
Value: 0b0000000000000000000000000000000000000000000000000000000000100000,
},
{
Value: 0b0000000000000000000000000000000000000000000000000000000001000000,
},
{
Value: 0b0000000000000000000000000000000000000000000000000000000010000000,
},
{
Value: 0b0000000000000000000000000000000000000000000000000000000100000000,
},
{
Value: 0b0000000000000000000000000000000000000000000000000000001000000000,
},
{
Value: 0b0000000000000000000000000000000000000000000000000000010000000000,
},
{
Value: 0b0000000000000000000000000000000000000000000000000000100000000000,
},
{
Value: 0b0000000000000000000000000000000000000000000000000001000000000000,
},
{
Value: 0b0000000000000000000000000000000000000000000000000010000000000000,
},
{
Value: 0b0000000000000000000000000000000000000000000000000100000000000000,
},
{
Value: 0b0000000000000000000000000000000000000000000000001000000000000000,
},
{
Value: 0b0000000000000000000000000000000000000000000000010000000000000000,
},
{
Value: 0b0000000000000000000000000000000000000000000000100000000000000000,
},
{
Value: 0b0000000000000000000000000000000000000000000001000000000000000000,
},
{
Value: 0b0000000000000000000000000000000000000000000010000000000000000000,
},
{
Value: 0b0000000000000000000000000000000000000000000100000000000000000000,
},
{
Value: 0b0000000000000000000000000000000000000000001000000000000000000000,
},
{
Value: 0b0000000000000000000000000000000000000000010000000000000000000000,
},
{
Value: 0b0000000000000000000000000000000000000000100000000000000000000000,
},
{
Value: 0b0000000000000000000000000000000000000001000000000000000000000000,
},
{
Value: 0b0000000000000000000000000000000000000010000000000000000000000000,
},
{
Value: 0b0000000000000000000000000000000000000100000000000000000000000000,
},
{
Value: 0b0000000000000000000000000000000000001000000000000000000000000000,
},
{
Value: 0b0000000000000000000000000000000000010000000000000000000000000000,
},
{
Value: 0b0000000000000000000000000000000000100000000000000000000000000000,
},
{
Value: 0b0000000000000000000000000000000001000000000000000000000000000000,
},
{
Value: 0b0000000000000000000000000000000010000000000000000000000000000000,
},
{
Value: 0b0000000000000000000000000000000100000000000000000000000000000000,
},
{
Value: 0b0000000000000000000000000000001000000000000000000000000000000000,
},
{
Value: 0b0000000000000000000000000000010000000000000000000000000000000000,
},
{
Value: 0b0000000000000000000000000000100000000000000000000000000000000000,
},
{
Value: 0b0000000000000000000000000001000000000000000000000000000000000000,
},
{
Value: 0b0000000000000000000000000010000000000000000000000000000000000000,
},
{
Value: 0b0000000000000000000000000100000000000000000000000000000000000000,
},
{
Value: 0b0000000000000000000000001000000000000000000000000000000000000000,
},
{
Value: 0b0000000000000000000000010000000000000000000000000000000000000000,
},
{
Value: 0b0000000000000000000000100000000000000000000000000000000000000000,
},
{
Value: 0b0000000000000000000001000000000000000000000000000000000000000000,
},
{
Value: 0b0000000000000000000010000000000000000000000000000000000000000000,
},
{
Value: 0b0000000000000000000100000000000000000000000000000000000000000000,
},
{
Value: 0b0000000000000000001000000000000000000000000000000000000000000000,
},
{
Value: 0b0000000000000000010000000000000000000000000000000000000000000000,
},
{
Value: 0b0000000000000000100000000000000000000000000000000000000000000000,
},
{
Value: 0b0000000000000001000000000000000000000000000000000000000000000000,
},
{
Value: 0b0000000000000010000000000000000000000000000000000000000000000000,
},
{
Value: 0b0000000000000100000000000000000000000000000000000000000000000000,
},
{
Value: 0b0000000000001000000000000000000000000000000000000000000000000000,
},
{
Value: 0b0000000000010000000000000000000000000000000000000000000000000000,
},
{
Value: 0b0000000000100000000000000000000000000000000000000000000000000000,
},
{
Value: 0b0000000001000000000000000000000000000000000000000000000000000000,
},
{
Value: 0b0000000010000000000000000000000000000000000000000000000000000000,
},
{
Value: 0b0000000100000000000000000000000000000000000000000000000000000000,
},
{
Value: 0b0000001000000000000000000000000000000000000000000000000000000000,
},
{
Value: 0b0000010000000000000000000000000000000000000000000000000000000000,
},
{
Value: 0b0000100000000000000000000000000000000000000000000000000000000000,
},
{
Value: 0b0001000000000000000000000000000000000000000000000000000000000000,
},
{
Value: 0b0010000000000000000000000000000000000000000000000000000000000000,
},
{
Value: 0b0100000000000000000000000000000000000000000000000000000000000000,
},
{
Value: 0b0111111111111111111111111111111111111111111111111111111111111110,
},
{
Value: 0b0111111111111111111111111111111111111111111111111111111111111101,
},
{
Value: 0b0111111111111111111111111111111111111111111111111111111111111011,
},
{
Value: 0b0111111111111111111111111111111111111111111111111111111111110111,
},
{
Value: 0b0111111111111111111111111111111111111111111111111111111111101111,
},
{
Value: 0b0111111111111111111111111111111111111111111111111111111111011111,
},
{
Value: 0b0111111111111111111111111111111111111111111111111111111110111111,
},
{
Value: 0b0111111111111111111111111111111111111111111111111111111101111111,
},
{
Value: 0b0111111111111111111111111111111111111111111111111111111011111111,
},
{
Value: 0b0111111111111111111111111111111111111111111111111111110111111111,
},
{
Value: 0b0111111111111111111111111111111111111111111111111111101111111111,
},
{
Value: 0b0111111111111111111111111111111111111111111111111111011111111111,
},
{
Value: 0b0111111111111111111111111111111111111111111111111110111111111111,
},
{
Value: 0b0111111111111111111111111111111111111111111111111101111111111111,
},
{
Value: 0b0111111111111111111111111111111111111111111111111011111111111111,
},
{
Value: 0b0111111111111111111111111111111111111111111111110111111111111111,
},
{
Value: 0b0111111111111111111111111111111111111111111111101111111111111111,
},
{
Value: 0b0111111111111111111111111111111111111111111111011111111111111111,
},
{
Value: 0b0111111111111111111111111111111111111111111110111111111111111111,
},
{
Value: 0b0111111111111111111111111111111111111111111101111111111111111111,
},
{
Value: 0b0111111111111111111111111111111111111111111011111111111111111111,
},
{
Value: 0b0111111111111111111111111111111111111111110111111111111111111111,
},
{
Value: 0b0111111111111111111111111111111111111111101111111111111111111111,
},
{
Value: 0b0111111111111111111111111111111111111111011111111111111111111111,
},
{
Value: 0b0111111111111111111111111111111111111110111111111111111111111111,
},
{
Value: 0b0111111111111111111111111111111111111101111111111111111111111111,
},
{
Value: 0b0111111111111111111111111111111111111011111111111111111111111111,
},
{
Value: 0b0111111111111111111111111111111111110111111111111111111111111111,
},
{
Value: 0b0111111111111111111111111111111111101111111111111111111111111111,
},
{
Value: 0b0111111111111111111111111111111111011111111111111111111111111111,
},
{
Value: 0b0111111111111111111111111111111110111111111111111111111111111111,
},
{
Value: 0b0111111111111111111111111111111101111111111111111111111111111111,
},
{
Value: 0b0111111111111111111111111111111011111111111111111111111111111111,
},
{
Value: 0b0111111111111111111111111111110111111111111111111111111111111111,
},
{
Value: 0b0111111111111111111111111111101111111111111111111111111111111111,
},
{
Value: 0b0111111111111111111111111111011111111111111111111111111111111111,
},
{
Value: 0b0111111111111111111111111110111111111111111111111111111111111111,
},
{
Value: 0b0111111111111111111111111101111111111111111111111111111111111111,
},
{
Value: 0b0111111111111111111111111011111111111111111111111111111111111111,
},
{
Value: 0b0111111111111111111111110111111111111111111111111111111111111111,
},
{
Value: 0b0111111111111111111111101111111111111111111111111111111111111111,
},
{
Value: 0b0111111111111111111111011111111111111111111111111111111111111111,
},
{
Value: 0b0111111111111111111110111111111111111111111111111111111111111111,
},
{
Value: 0b0111111111111111111101111111111111111111111111111111111111111111,
},
{
Value: 0b0111111111111111111011111111111111111111111111111111111111111111,
},
{
Value: 0b0111111111111111110111111111111111111111111111111111111111111111,
},
{
Value: 0b0111111111111111101111111111111111111111111111111111111111111111,
},
{
Value: 0b0111111111111111011111111111111111111111111111111111111111111111,
},
{
Value: 0b0111111111111110111111111111111111111111111111111111111111111111,
},
{
Value: 0b0111111111111101111111111111111111111111111111111111111111111111,
},
{
Value: 0b0111111111111011111111111111111111111111111111111111111111111111,
},
{
Value: 0b0111111111110111111111111111111111111111111111111111111111111111,
},
{
Value: 0b0111111111101111111111111111111111111111111111111111111111111111,
},
{
Value: 0b0111111111011111111111111111111111111111111111111111111111111111,
},
{
Value: 0b0111111110111111111111111111111111111111111111111111111111111111,
},
{
Value: 0b0111111101111111111111111111111111111111111111111111111111111111,
},
{
Value: 0b0111111011111111111111111111111111111111111111111111111111111111,
},
{
Value: 0b0111110111111111111111111111111111111111111111111111111111111111,
},
{
Value: 0b0111101111111111111111111111111111111111111111111111111111111111,
},
{
Value: 0b0111011111111111111111111111111111111111111111111111111111111111,
},
{
Value: 0b0110111111111111111111111111111111111111111111111111111111111111,
},
{
Value: 0b0101111111111111111111111111111111111111111111111111111111111111,
},
{
Value: 0b0011111111111111111111111111111111111111111111111111111111111111,
},
{
Value: 0b0111111111111111111111111111111111111111111111111111111111111111,
},
{
Value: 0b0000000000000000000000000000000000000000100000000000000000000001,
},
{
Value: 0b0100000000000000000000000000000000000001000000000000000000000000,
},
{
Value: 0b0100000000000000000000000000000000000001100000000000000000000001,
},
}
for testNumber, test := range tests {
first, second := decompile(test.Value)
actual := compile(first, second)
if expected := test.Value; expected != actual {
t.Errorf("For test #%d, the actual re-compiled value of the decompiled values is not what was expected.", testNumber)
t.Logf("EXPECTED: %064b", expected)
t.Logf("ACTUAL: %064b", actual)
t.Logf("FIRST %064b", first)
t.Logf("SECOND %064b", second)
continue
}
}
}