diff --git a/MyRam-WIP/CreateRam/content/OR_PORT.circ b/MyRam-WIP/CreateRam/content/OR_PORT.circ
deleted file mode 100755
index 2e773d2..0000000
--- a/MyRam-WIP/CreateRam/content/OR_PORT.circ
+++ /dev/null
@@ -1,298 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/MyRam-WIP/CreateRam/content/RAM.circ b/MyRam-WIP/CreateRam/content/RAM.circ
deleted file mode 100755
index 02b235e..0000000
--- a/MyRam-WIP/CreateRam/content/RAM.circ
+++ /dev/null
@@ -1,283 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/MyRam-WIP/CreateRam/data.go b/MyRam-WIP/CreateRam/data.go
deleted file mode 100644
index 2fad5d9..0000000
--- a/MyRam-WIP/CreateRam/data.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package main
-
-import "fmt"
-
-type pair struct {
- x int
- y int
-}
-
-func newPair(x int, y int) pair {
- return pair{x, y}
-}
-
-type wire struct {
- from pair
- to pair
-}
-
-func newWire(from pair, to pair) wire {
- return wire{from, to}
-}
-
-func (w wire) toCircuit() string {
- return fmt.Sprintf("", w.from.x, w.from.y, w.to.x, w.to.y)
-}
-
-type pin struct {
- loc pair
- name string
-}
-
-func newPin(loc pair, name string) pin {
- return pin{loc: loc, name: name}
-}
-
-func (p pin) toCircuit() string {
- return fmt.Sprintf(" %s %s ", p.loc.x, p.loc.y, newLine, p.name, newLine)
-}
-
-type ramByte struct {
- loc pair
-}
-
-func newRAMByte(loc pair) ramByte {
- return ramByte{loc: loc}
-}
-
-func (r ramByte) toCircuit() string {
- return fmt.Sprintf(" %s %s ", r.loc.x, r.loc.y, newLine, newLine)
-}
diff --git a/MyRam-WIP/CreateRam/main.go b/MyRam-WIP/CreateRam/main.go
deleted file mode 100644
index f9934e5..0000000
--- a/MyRam-WIP/CreateRam/main.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package main
-
-import (
- "fmt"
- "io/ioutil"
- "log"
- "math"
-)
-
-const ramFileName = "../RAM.circ"
-const orPortFileName = "../OR_PORT.circ"
-const fileMode = 777
-const newLine = "\n"
-
-const amntBitsComputer = 8 //this will not work "out of the box" if you change this
-
-func getMaxBytesRAM() int {
- return int(math.Pow(2, amntBitsComputer))
-}
-
-func main() {
- fmt.Println("MENU: ")
- fmt.Println("1. Generate RAM")
- fmt.Println("2. Create PortOr")
-
- fmt.Print("Menu item choosen: ")
- var item int
- _, err := fmt.Scanf("%d", &item)
- if err != nil {
- log.Fatal(err)
- }
-
- switch item {
- case 1:
- generateRAMCircuitWithUser()
- break
- case 2:
- generateOrPortWithUser()
- break
- }
-
- fmt.Println()
- fmt.Println("End of execution")
-}
-
-func generateOrPortWithUser() {
- fmt.Print("Amount of inputs: ")
- var amntInputs int
- _, err := fmt.Scanf("%d", &amntInputs)
- if err != nil {
- log.Fatal(err)
- }
-
- orPortCircuitStr, errOrPort := generateOrPort(amntInputs)
- if errOrPort != nil {
- log.Fatal(errOrPort)
- }
-
- errWrite := ioutil.WriteFile(orPortFileName, []byte(orPortCircuitStr), fileMode)
- if errWrite != nil {
- log.Fatal(errWrite)
- }
-}
-
-func generateRAMCircuitWithUser() {
- fmt.Print("Amount of bytes in the RAM: ")
- var amntBytes int
- _, err := fmt.Scanf("%d", &amntBytes)
- if err != nil {
- log.Fatal(err)
- }
- if amntBytes <= 0 {
- amntBytes = getMaxBytesRAM() - 1
- }
-
- ramCircuitStr := generateRAMCircuit(amntBytes)
- errWrite := ioutil.WriteFile(ramFileName, []byte(ramCircuitStr), fileMode)
- if errWrite != nil {
- log.Fatal(err)
- }
-}
diff --git a/MyRam-WIP/CreateRam/portOR.go b/MyRam-WIP/CreateRam/portOR.go
deleted file mode 100644
index 2633008..0000000
--- a/MyRam-WIP/CreateRam/portOR.go
+++ /dev/null
@@ -1,162 +0,0 @@
-package main
-
-import (
- "errors"
- "fmt"
-)
-
-const maxInputsPort = 32
-
-const xInputs = 150
-const yFirstPort = 300
-const yDistanceBwtInputs = 10
-
-const spaceBtwPorts = 100
-const xDistanceInputPort = 100
-const yDistancePortFromFirstInput = 160
-const widthPort = 50
-
-const imenseOrInputNamePrefix = "input"
-
-func generateOrPort(amntInputs int) (string, error) {
- imenseOrPort := newImenseOrPort()
-
- if amntInputs > maxInputsPort*maxInputsPort {
- return "", errors.New("This port is not able to deal with this much inputs")
- }
-
- amntInputsRemaining := amntInputs
- yCurPort := yFirstPort
- for amntInputsRemaining > 0 {
- var amntInputsCurPort int
- if amntInputsRemaining > maxInputsPort {
- amntInputsCurPort = maxInputsPort
- } else {
- amntInputsCurPort = amntInputsRemaining
- }
-
- portLoc := newPair(xInputs+xDistanceInputPort, yCurPort)
- imenseOrPort.addOrPort(portLoc)
-
- for i := 0; i < amntInputsCurPort; i++ {
- y := yCurPort - yDistancePortFromFirstInput + i*yDistanceBwtInputs
- if i >= maxInputsPort/2 {
- y += yDistanceBwtInputs
- }
-
- inputPinLoc := newPair(xInputs, y)
- imenseOrPort.addInputPins(inputPinLoc)
-
- wireFrom := inputPinLoc
- wireTo := newPair(portLoc.x-widthPort, inputPinLoc.y)
- imenseOrPort.addWire(newWire(wireFrom, wireTo))
- }
-
- yCurPort += spaceBtwPorts + (maxInputsPort+1)*yDistanceBwtInputs
- amntInputsRemaining -= maxInputsPort
- }
-
- return imenseOrPort.toCircuit(), nil
-}
-
-/////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////
-///////////////////////////////// PORT //////////////////////////////////
-/////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////
-
-type portType string
-
-const (
- orPort = "OR Gate"
- andPort = "AND Gate"
- notPort = "NOT Gate"
-)
-
-type direction string
-
-const (
- south = "south"
- north = "north"
- east = "east"
- west = "west"
-)
-
-type port struct {
- loc pair
- amntInputs int
- portType portType
- facingDirection direction
-}
-
-func newPort(loc pair, amntInputs int, portType portType, facingDirection direction) port {
- return port{loc: loc, amntInputs: amntInputs, portType: portType, facingDirection: facingDirection}
-}
-
-func (p port) toCircuit() string {
- ret := fmt.Sprintf("", p.loc.x, p.loc.y, p.portType)
- ret += newLine + fmt.Sprintf("", p.facingDirection)
- ret += newLine + fmt.Sprintf("", p.amntInputs)
- ret += newLine + ""
- return ret
-}
-
-/////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////
-//////////////////////////// IMENSE OR PORT /////////////////////////////
-/////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////
-
-type imenseOrPort struct {
- ports []port
- wires []wire
- inputPins []pin
- outputPin pin
-}
-
-func newImenseOrPort() imenseOrPort {
- return imenseOrPort{}
-}
-
-func (p *imenseOrPort) addOrPort(loc pair) {
- port := newPort(loc, maxInputsPort, orPort, east)
- p.ports = append(p.ports, port)
-}
-
-func (p *imenseOrPort) addWire(wire wire) {
- p.wires = append(p.wires, wire)
-}
-
-func (p *imenseOrPort) addInputPins(loc pair) {
- pinName := fmt.Sprintf("%s%d", imenseOrInputNamePrefix, len(p.inputPins))
- p.inputPins = append(p.inputPins, newPin(loc, pinName))
-}
-
-func (p *imenseOrPort) setOutputPins(pin pin) {
- p.outputPin = pin
-}
-
-func (p imenseOrPort) toCircuit() string {
- portsStr := ""
- for _, port := range p.ports {
- portsStr += port.toCircuit() + newLine
- }
-
- wiresStr := ""
- for _, wire := range p.wires {
- wiresStr += wire.toCircuit() + newLine
- }
-
- inputsStr := ""
- for _, pin := range p.inputPins {
- inputsStr += pin.toCircuit() + newLine
- }
-
- outputStr := p.outputPin.toCircuit()
-
- return portsStr + wiresStr + outputStr + inputsStr
-}
diff --git a/MyRam-WIP/CreateRam/ram.go b/MyRam-WIP/CreateRam/ram.go
deleted file mode 100644
index 771de59..0000000
--- a/MyRam-WIP/CreateRam/ram.go
+++ /dev/null
@@ -1,125 +0,0 @@
-package main
-
-import (
- "errors"
- "fmt"
- "log"
-)
-
-const ramInputNamePrefix = "input"
-
-const xPins = 100
-const yFirstPin = 120
-const yDistanceBtwPins = 40
-
-const yByteRams = 870
-const xFirstByteRAM = 840
-const xDistanceBtwByteRams = 250
-const xDeltaStartWireFromByteRams = -180
-const xDistanceBtwByteRAMInputs = 20
-const yDeltaStartWireFromByteRams = -160
-
-func getInputBeforeBits() []string {
- inputs := []string{"is_write", "select_value"}
- for i := 0; i < amntBitsComputer; i++ {
- inputs = append(inputs, fmt.Sprintf("%s%d", ramInputNamePrefix, i))
- }
- return inputs
-}
-
-// WIRE FROM BYTE RAM HAS TO START IN BYTE_RAM AND GO UP
-// BYTE RAM HAVE TO BE ADDED IN ORDER (from left to right)
-
-func generateRAMCircuit(amntBytes int) string {
- if amntBytes >= getMaxBytesRAM() {
- log.Fatal(errors.New("Computer won't be able to access these bytes"))
- }
-
- inputs := getInputBeforeBits()
- ram := newRAM(len(inputs))
-
- for i := 0; i < len(inputs); i++ {
- locPin := newPair(xPins, yFirstPin+i*yDistanceBtwPins)
- curPin := newPin(locPin, inputs[i])
- ram.addPin(curPin)
-
- startWire := locPin
- ram.addWireFromPin(startWire, i)
- }
-
- for i := 0; i < amntBytes; i++ {
- locByteRAM := newPair(xFirstByteRAM+i*xDistanceBtwByteRams, yByteRams)
- byteRAM := newRAMByte(locByteRAM)
- ram.addRAMByte(byteRAM)
-
- for i := 0; i < len(inputs); i++ {
- xWire := (locByteRAM.x + xDeltaStartWireFromByteRams) + i*xDistanceBtwByteRAMInputs
- yWire := byteRAM.loc.y + yDeltaStartWireFromByteRams
- startWire := newPair(xWire, yWire)
-
- bitIndex := len(inputs) - i - 1
- ram.addWireFromByte(startWire, bitIndex)
- }
- }
-
- return ram.toCircuit()
-}
-
-type ram struct {
- pinWiresStart []pair
- wires []wire
- inputPins []pin
- ramBytes []ramByte
- // TODO:
- // outputPins []pin
- // orPorts []port
-}
-
-func newRAM(amntPins int) ram {
- return ram{pinWiresStart: make([]pair, amntPins)}
-}
-
-func (r *ram) addWireFromPin(pinWireStart pair, i int) {
- r.pinWiresStart[i] = pinWireStart
-}
-
-func (r *ram) addWireFromByte(byteWireStart pair, i int) {
- intersectionWires := newPair(byteWireStart.x, r.pinWiresStart[i].y)
-
- wireFromByte := newWire(byteWireStart, intersectionWires)
- r.wires = append(r.wires, wireFromByte)
-
- fromPinWire := r.pinWiresStart[i]
- toPinWire := intersectionWires
-
- wireFromPin := newWire(fromPinWire, toPinWire)
- r.wires = append(r.wires, wireFromPin)
- r.pinWiresStart[i] = toPinWire
-}
-
-func (r *ram) addPin(pin pin) {
- r.inputPins = append(r.inputPins, pin)
-}
-
-func (r *ram) addRAMByte(ramByte ramByte) {
- r.ramBytes = append(r.ramBytes, ramByte)
-}
-
-func (r ram) toCircuit() string {
- wiresStr := ""
- for _, wire := range r.wires {
- wiresStr += wire.toCircuit() + newLine
- }
-
- pinsStr := ""
- for _, pin := range r.inputPins {
- pinsStr += pin.toCircuit() + newLine
- }
-
- ramBytesStr := ""
- for _, ramByte := range r.ramBytes {
- ramBytesStr += ramByte.toCircuit() + newLine
- }
-
- return wiresStr + pinsStr + ramBytesStr
-}
diff --git a/MyRam-WIP/my_ram.circ b/MyRam-WIP/my_ram.circ
deleted file mode 100644
index 161bb27..0000000
--- a/MyRam-WIP/my_ram.circ
+++ /dev/null
@@ -1,617 +0,0 @@
-
-
-This file is intended to be loaded by Logisim-evolution (https://github.com/reds-heig/logisim-evolution).
-
-
-
-
-
-
-
-
-
-
-
-
-
- addr/data: 8 8
-0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/README.md b/README.md
index 2689e55..69d707b 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,8 @@
### 3. [🔀 Code Flow and Tips](#-code-flow-and-tips)
### 4. [⌨️ Machine Code Example](#-machine-code-example)
### 5. [▶️ Run](#️-run)
-### 6. [📄 Contributing Guidelines](#-contributing-guidelines)
+### 6. [▶️ Test](#️-test)
+### 7. [📄 Contributing Guidelines](#-contributing-guidelines)
@@ -231,5 +232,17 @@ You can watch [this video](https://www.youtube.com/watch?v=NAITQqdOw7c) as an in
+# ▶️ Test
+To test the circuit, run the following command:
+```sh
+./test/test.sh
+```
+
+
+
+---
+
+
+
# 📄 Contributing Guidelines
Check out the contributing guidelines [here](https://github.com/Open-Machine/Circuits/blob/master/CONTRIBUTING.md).
diff --git a/test/README.md b/test/README.md
new file mode 100644
index 0000000..eb668b7
--- /dev/null
+++ b/test/README.md
@@ -0,0 +1,136 @@
+# Test
+
+Code: 16 bits = instruction (4 bits) + parameter (12 bits). For example, in the command ```0x1202```, the instruction is ```0x1``` and the parameter is ```0x202```.
+
+### Ram
+```
+0000 code 9000 0000x10 memory
+```
+
+### Memory
+50th = 32 = next
+```sh
+0000 # aux (32)
+0101 # a (33)
+1234 # b (34)
+0000 # zero (35)
+0001 # positive (36)
+f000 # negative (37)
+ffff # max (38)
+8888 # end (39)
+```
+
+### Code
+```sh
+{test sum and subtraction: 0x3 and 0x4}
+{switch a and b and print a position}
+
+# a + b (1-2)
+1033
+3034
+
+# print a + b (3-4)
+2032
+8032
+{expect 1335}
+
+# a - b (5-6)
+1033
+4034
+{expect EECD}
+
+---
+
+{test get and update memory: 0x1 and 0x2}
+{switch a and b and print a position}
+
+# aux = a (7-8)
+1033
+2032
+
+# a = b (9-A)
+1034
+2033
+
+# b = aux (B-C)
+1032
+2034
+
+# print b (D)
+8033
+{expect 1234}
+
+---
+
+{test jumps}
+
+# always jump (E-F)
+a010
+8038
+{doesnt expect print}
+
+
+# jump > 0 for negative (10-12)
+1037
+b013
+8038
+{expect print ffff}
+
+# jump > 0 for zero (13-15)
+1035
+b016
+8038
+{expect print ffff}
+
+# jump > 0 for positive (16-18)
+1036
+b019
+8038
+{doesnt expect print}
+
+
+# jump = 0 for negative (19-1B)
+1037
+d01B
+8038
+{expect print ffff}
+
+# jump = 0 for positive (1C-1E)
+1036
+d01F
+8038
+{expect print ffff}
+
+# jump = 0 for zero (1F-21)
+1035
+d022
+8038
+{doesnt expect print}
+
+
+# jump < 0 for zero (22-24)
+1035
+f025
+8038
+{expect print ffff}
+
+# jump < 0 for positive (25-27)
+1036
+f028
+8038
+{expect print ffff}
+
+# jump < 0 for negative (28-2A)
+1037
+f02B
+8038
+{doesnt expect print}
+
+---
+
+# kill (2B-2C)
+8039
+{expect 8888}
+9000
+
+```
diff --git a/test/go.mod b/test/go.mod
new file mode 100644
index 0000000..c7776bf
--- /dev/null
+++ b/test/go.mod
@@ -0,0 +1,3 @@
+module circuit-test
+
+go 1.16
diff --git a/test/main.go b/test/main.go
new file mode 100644
index 0000000..569f156
--- /dev/null
+++ b/test/main.go
@@ -0,0 +1,83 @@
+package main
+
+import (
+ "bufio"
+ "fmt"
+ "io"
+ "os"
+ "os/exec"
+ "strconv"
+ "strings"
+)
+
+func main() {
+ stdout, err := runCommand("java", "-jar", "../logisim-evolution.jar", "../main.circ", "-load", "program", "-tty", "table")
+ if err != nil {
+ os.Exit(1)
+ }
+
+ expected := []string{"1335", "EECD", "1234", "ffff", "ffff", "ffff", "ffff", "ffff", "ffff", "8888"}
+
+ scanner := bufio.NewScanner(stdout)
+ scanner.Scan() // ignores first print
+ var i = 0
+ for scanner.Scan() {
+ line := scanner.Text()
+
+ binaryStr := strings.ReplaceAll(line, " ", "")[0:16]
+ gotNum, errBinary := binaryStringToNumber(binaryStr)
+
+ expectedNum, errHex := hexStringToNumber(expected[i])
+
+ if errBinary != nil || errHex != nil {
+ fmt.Printf("Parsing error. ErrBinary: '%t', ErrHex: '%t'.", errBinary, errHex)
+ }
+ if gotNum != expectedNum {
+ fmt.Printf("Got different then expected. Expected: %d, but got: %d.\n", expectedNum, gotNum)
+ }
+
+ i++
+ if len(expected) == i {
+ if scanner.Scan() {
+ fmt.Printf("Size is different")
+ }
+ fmt.Print("breaked")
+ break
+ }
+ }
+
+ fmt.Print("closed")
+ stdout.Close()
+}
+
+func binaryStringToNumber(s string) (uint64, error) {
+ ui, err := strconv.ParseUint(s, 2, 64)
+ if err != nil {
+ return 0, err
+ }
+ return ui, nil
+}
+
+func hexStringToNumber(s string) (uint64, error) {
+ ui, err := strconv.ParseUint(s, 16, 64)
+ if err != nil {
+ return 0, err
+ }
+ return ui, nil
+}
+
+func runCommand(name string, arg ...string) (io.ReadCloser, error) {
+ cmd := exec.Command(name, arg...)
+
+ stdout, err := cmd.StdoutPipe()
+ if err != nil {
+ return nil, err
+ }
+
+ err = cmd.Start()
+ if err != nil {
+ return nil, err
+ }
+
+ return stdout, nil
+}
diff --git a/test/main_test.go b/test/main_test.go
new file mode 100644
index 0000000..edf67bf
--- /dev/null
+++ b/test/main_test.go
@@ -0,0 +1 @@
+// TODO: migrate main.go to test
\ No newline at end of file
diff --git a/test/program b/test/program
new file mode 100644
index 0000000..da243af
--- /dev/null
+++ b/test/program
@@ -0,0 +1,2 @@
+v2.0 raw
+0000 1033 3034 2032 8032 1033 4034 1033 2032 1034 2033 1032 2034 8033 a010 8038 1037 b013 8038 1035 b016 8038 1036 b019 8038 1037 d01B 8038 1036 d01F 8038 1035 d022 8038 1035 f025 8038 1036 f028 8038 1037 f02B 8038 8039 9000 0000 0000 0000 0000 0000 0000 0101 1234 0000 0001 f000 ffff 8888