text:
package intcodecpu

import (
	"fmt"
	"testing"

	"aoc2019/common"
)

func TestOpCodeToString(t *testing.T) {
	common.Assert(t, opERR.String() == "ERR", "opERR did not return expected string")
	common.Assert(t, opADD.String() == "ADD", "opADD did not return expected string")
	common.Assert(t, opMUL.String() == "MUL", "opMUL did not return expected string")
	common.Assert(t, opINP.String() == "INP", "opINP did not return expected string")
	common.Assert(t, opOUT.String() == "OUT", "opOUT did not return expected string")
	common.Assert(t, opJMT.String() == "JMT", "opJMT did not return expected string")
	common.Assert(t, opJMF.String() == "JMF", "opJMF did not return expected string")
	common.Assert(t, opLES.String() == "LES", "opLES did not return expected string")
	common.Assert(t, opEQU.String() == "EQU", "opEQU did not return expected string")
	common.Assert(t, opCRB.String() == "CRB", "opCRB did not return expected string")
	common.Assert(t, opHLT.String() == "HLT", "opHLT did not return expected string")
	common.Assert(t, opCode(42).String() == "Unknown OpCode", "Invalid opCode did not return expected string")
}

func executeAndCheckResult(t *testing.T, cpu *CPU, epc uint) {
	done, err := cpu.executeOpCode()
	common.Assert(t, err == nil, "Test failed with an error: %v", err)
	common.Assert(t, done == false, "Test failed with the done flag set")
	common.Assert(t, cpu.pc == epc, "Test failed with unexpected pc: %v, excpected %v", cpu.pc, epc)
}

func TestOpADD(t *testing.T) {
	tt := []struct {
		base     int
		code     []int
		expected int
	}{
		{base: 2, code: []int{1, 5, 6, 2, 99, 21, 21, 10, 12}, expected: 42},     // pos + pos = 21 + 21
		{base: 2, code: []int{101, 5, 6, 2, 99, 21, 21, 10, 12}, expected: 26},   // im + pos = 5 + 21
		{base: 2, code: []int{201, 5, 6, 2, 99, 21, 21, 10, 12}, expected: 31},   // rel + pos = 10 + 21
		{base: 2, code: []int{1001, 5, 6, 2, 99, 21, 21, 10, 12}, expected: 27},  // pos + im = 21 + 6
		{base: 2, code: []int{2001, 5, 6, 2, 99, 21, 21, 10, 12}, expected: 33},  // pos + rel = 21 + 12
		{base: 2, code: []int{1101, 5, 6, 2, 99, 21, 21, 10, 12}, expected: 11},  // im + im = 5 + 6
		{base: 2, code: []int{2201, 5, 6, 2, 99, 21, 21, 10, 12}, expected: 22},  // rel + rel = 10 + 12
		{base: 2, code: []int{22201, 5, 6, 2, 99, 21, 21, 10, 12}, expected: 22}, // rel + rel = 10 + 12 => rel
	}
	cpu := &CPU{}
	for i, tc := range tt {
		t.Run(fmt.Sprintf("Test_%v", i), func(t *testing.T) {
			cpu.memory = tc.code
			cpu.pc = 0
			cpu.relBase = tc.base
			executeAndCheckResult(t, cpu, 4)
			if tc.code[0]/10000 == 0 {
				common.Assert(t, cpu.memory[2] == tc.expected, "Test failed for %v with unexpected result %v, excpected %v", tc.code[0], cpu.memory[2], tc.expected)
			} else {
				common.Assert(t, cpu.memory[4] == tc.expected, "Test failed for %v with unexpected result %v, excpected %v", tc.code[0], cpu.memory[4], tc.expected)
			}
		})
	}
}

func TestOpCRB(t *testing.T) {
	tt := []struct {
		base     int
		code     []int
		expected int
	}{
		{base: 5, code: []int{9, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9}, expected: 7},    // base += pos
		{base: 5, code: []int{109, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9}, expected: 8},  // base += im
		{base: 5, code: []int{209, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9}, expected: 12}, // base += rel [base + pos[base + 3] == 5 + 7]
		{base: 5, code: []int{109, -5}, expected: 0},                            // base += im
	}
	cpu := &CPU{}
	for i, tc := range tt {
		t.Run(fmt.Sprintf("Test_%v", i), func(t *testing.T) {
			cpu.memory = tc.code
			cpu.pc = 0
			cpu.relBase = tc.base
			executeAndCheckResult(t, cpu, 2)
			common.Assert(t, cpu.relBase == tc.expected, "Test failed with unexpected result %v, excpected %v", cpu.relBase, tc.expected)
		})
	}
}

func TestOpEQU(t *testing.T) {
	tt := []struct {
		base     int
		code     []int
		expected int
	}{
		{base: 2, code: []int{8, 4, 5, 0, 42, 42, -1, -2}, expected: 1},    // pos == pos = 42 == 42
		{base: 2, code: []int{8, 4, 5, 0, 42, 44, -1, -1}, expected: 0},    // pos == pos = 42 == 44
		{base: 2, code: []int{108, 4, 5, 0, -1, 4, -2, -3}, expected: 1},   // im  == pos =  4 ==  4
		{base: 2, code: []int{108, 4, 5, 0, -1, 5, -1, -1}, expected: 0},   // im  == pos =  4 ==  5
		{base: 2, code: []int{208, 4, 5, 0, -1, 22, 22, -2}, expected: 1},  // rel == pos = 22 == 22
		{base: 2, code: []int{208, 4, 5, 0, -1, 22, 23, -1}, expected: 0},  // rel == pos = 23 == 22
		{base: 2, code: []int{1008, 4, 5, 0, 5, -1, -2, -3}, expected: 1},  // pos == im  =  5 ==  5
		{base: 2, code: []int{1008, 4, 5, 0, 2, -1, -1, -1}, expected: 0},  // pos == im  =  2 ==  5
		{base: 2, code: []int{2008, 4, 5, 0, 2, -1, -2, 2}, expected: 1},   // pos == rel =  2 ==  2
		{base: 2, code: []int{2008, 4, 5, 0, 2, -1, -2, 3}, expected: 0},   // pos == rel =  2 ==  3
		{base: 2, code: []int{1108, 7, 7, 0, -1, -2, -3, -4}, expected: 1}, // im  == im  =  7 ==  7
		{base: 2, code: []int{1108, 6, 8, 0, -1, -1, -1, -1}, expected: 0}, // im  == im  =  6 ==  8
		{base: 2, code: []int{2208, 4, 5, 0, -1, -2, 8, 8}, expected: 1},   // rel == rel =  8 ==  8
		{base: 2, code: []int{2208, 4, 5, 0, -1, -1, 8, 9}, expected: 0},   // rel == rel =  8 ==  9
	}
	cpu := &CPU{}
	for i, tc := range tt {
		t.Run(fmt.Sprintf("Test_%v", i), func(t *testing.T) {
			cpu.memory = tc.code
			cpu.pc = 0
			cpu.relBase = tc.base
			executeAndCheckResult(t, cpu, 4)
			common.Assert(t, cpu.memory[0] == tc.expected, "Test failed with unexpected result %v, excpected %v", cpu.memory[0], tc.expected)
		})
	}
}

func TestOpHLT(t *testing.T) {
	cpu := &CPU{}
	cpu.memory = []int{99}
	done, err := cpu.executeOpCode()
	common.Assert(t, err == nil, "Test failed with an error: %v", err)
	common.Assert(t, done == true, "Test failed with the done flag set")
	common.Assert(t, cpu.pc == 0, "Test failed with unexpected pc: %v, excpected 0", cpu.pc)
}

func TestOpINP(t *testing.T) {
	cpu := &CPU{memory: []int{3, 0}, stdIn: func() int { return 42 }}
	executeAndCheckResult(t, cpu, 2)
	common.Assert(t, cpu.memory[0] == 42, "Test failed with unexpected result %v, excpected 42", cpu.memory[0])
}

func TestOpJMF(t *testing.T) {
	tt := []struct {
		base     int
		code     []int
		expected uint
	}{
		{base: 2, code: []int{6, 3, 4, 0, 42}, expected: 42},   // pos, pos => 0, 42, jump
		{base: 2, code: []int{6, 3, 4, 1, 42}, expected: 3},    // pos, pos => 1, 42, no jump
		{base: 2, code: []int{106, 0, 4, 0, 42}, expected: 42}, // im,  pos => 0, 42, jump
		{base: 2, code: []int{106, 3, 4, 0, 42}, expected: 3},  // im,  pos => 3, 42, no jump
		{base: 2, code: []int{1006, 3, 4, 0, 42}, expected: 4}, // pos, im  => 0,  4, jump
		{base: 2, code: []int{1006, 3, 4, 1, 42}, expected: 3}, // pos, im  => 1,  4, no jump
		{base: 2, code: []int{1106, 0, 4, 0, 42}, expected: 4}, // im,  im  => 0,  4, jump
		{base: 2, code: []int{1106, 3, 4, 0, 42}, expected: 3}, // im,  im  => 3,  4, no jump
	}
	cpu := &CPU{}
	for i, tc := range tt {
		t.Run(fmt.Sprintf("Test_%v", i), func(t *testing.T) {
			cpu.memory = tc.code
			cpu.pc = 0
			cpu.relBase = tc.base
			executeAndCheckResult(t, cpu, tc.expected)
		})
	}
}

func TestOpJMT(t *testing.T) {
	tt := []struct {
		base     int
		code     []int
		expected uint
	}{
		{base: 2, code: []int{5, 3, 4, 0, 42}, expected: 3},    // pos, pos => 0, 42, no jump
		{base: 2, code: []int{5, 3, 4, 1, 42}, expected: 42},   // pos, pos => 1, 42, jump
		{base: 2, code: []int{105, 0, 4, 0, 42}, expected: 3},  // im,  pos => 0, 42, no jump
		{base: 2, code: []int{105, 3, 4, 0, 42}, expected: 42}, // im,  pos => 3, 42, jump
		{base: 2, code: []int{1005, 3, 4, 0, 42}, expected: 3}, // pos, im  => 0,  4, no jump
		{base: 2, code: []int{1005, 3, 4, 1, 42}, expected: 4}, // pos, im  => 1,  4, jump
		{base: 2, code: []int{1105, 0, 4, 0, 42}, expected: 3}, // im,  im  => 0,  4, no jump
		{base: 2, code: []int{1105, 3, 4, 0, 42}, expected: 4}, // im,  im  => 3,  4, jump
	}
	cpu := &CPU{}
	for i, tc := range tt {
		t.Run(fmt.Sprintf("Test_%v", i), func(t *testing.T) {
			cpu.memory = tc.code
			cpu.pc = 0
			cpu.relBase = tc.base
			executeAndCheckResult(t, cpu, tc.expected)
		})
	}
}

func TestOpLES(t *testing.T) {
	tt := []struct {
		base     int
		code     []int
		expected int
	}{
		{base: 2, code: []int{7, 4, 5, 0, 1, 42}, expected: 1},     // pos < pos =  1 < 42
		{base: 2, code: []int{7, 4, 5, 0, 42, 42}, expected: 0},    // pos < pos = 42 < 42
		{base: 2, code: []int{107, 4, 5, 0, 1, 42}, expected: 1},   // im  < pos =  4 < 42
		{base: 2, code: []int{107, 4, 5, 0, 1, 4}, expected: 0},    // im  < pos =  4 <  4
		{base: 2, code: []int{1007, 4, 5, 0, 1, 42}, expected: 1},  // pos < im  =  1 <  5
		{base: 2, code: []int{1007, 4, 5, 0, 42, 42}, expected: 0}, // pos < im  = 42 <  5
		{base: 2, code: []int{1107, 4, 5, 0, 1, 42}, expected: 1},  // im  < im  =  4 <  5
		{base: 2, code: []int{1107, 4, 3, 0, 1, 42}, expected: 0},  // im  < im  =  4 <  3
	}
	cpu := &CPU{}
	for i, tc := range tt {
		t.Run(fmt.Sprintf("Test_%v", i), func(t *testing.T) {
			cpu.memory = tc.code
			cpu.pc = 0
			cpu.relBase = tc.base
			executeAndCheckResult(t, cpu, 4)
			common.Assert(t, cpu.memory[0] == tc.expected, "Test failed with unexpected result %v, excpected %v", cpu.memory[0], tc.expected)
		})
	}
}

func TestOpMUL(t *testing.T) {
	tt := []struct {
		base     int
		code     []int
		expected int
	}{
		{base: 2, code: []int{2, 5, 6, 0, 99, 1, 42}, expected: 42},     // pos * pos = 1 * 42
		{base: 2, code: []int{102, 5, 6, 0, 99, 1, 42}, expected: 210},  // im * pos = 5 * 42
		{base: 2, code: []int{1002, 5, 6, 0, 99, 1, 42}, expected: 6},   // pos * im = 1 * 6
		{base: 2, code: []int{1102, 5, 6, 0, 99, 1, 42}, expected: 30},  // im * im = 5 * 6
		{base: 2, code: []int{10002, 5, 6, 0, 99, 1, 42}, expected: 42}, // pos * pos = 1 * 42
	}
	cpu := &CPU{}
	for i, tc := range tt {
		t.Run(fmt.Sprintf("Test_%v", i), func(t *testing.T) {
			cpu.memory = tc.code
			cpu.pc = 0
			cpu.relBase = tc.base
			executeAndCheckResult(t, cpu, 4)
			common.Assert(t, cpu.memory[0] == tc.expected, "Test failed with unexpected result %v, excpected %v", cpu.memory[0], tc.expected)
		})
	}
}

func TestOpOUT(t *testing.T) {
	tt := []struct {
		base     int
		code     []int
		expected int
	}{
		{base: 2, code: []int{4, 0}, expected: 4},         // pos -> out
		{base: 2, code: []int{104, 0}, expected: 0},       // im -> out
		{base: 2, code: []int{1004, 0}, expected: 1004},   // pos -> out
		{base: 2, code: []int{1104, 0}, expected: 0},      // im -> out
		{base: 2, code: []int{10004, 0}, expected: 10004}, // pos -> out
	}
	out := -1
	cpu := &CPU{memory: []int{3, 0}, stdOut: func(data int) { out = data }}
	for i, tc := range tt {
		t.Run(fmt.Sprintf("Test_%v", i), func(t *testing.T) {
			cpu.memory = tc.code
			cpu.pc = 0
			cpu.relBase = tc.base
			executeAndCheckResult(t, cpu, 2)
			common.Assert(t, out == tc.expected, "Test failed with unexpected result %v, excpected %v", out, tc.expected)
		})
	}
}

license: Unlicense


text:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE eagle SYSTEM "eagle.dtd">
<eagle version="7.2.0">
<drawing>
<settings>
<setting alwaysvectorfont="no"/>
<setting verticaltext="up"/>
</settings>
<grid distance="5" unitdist="mil" unit="mil" style="dots" multiple="1" display="yes" altdistance="0.25" altunitdist="mm" altunit="mm"/>
<layers>
<layer number="1" name="Top" color="4" fill="1" visible="yes" active="yes"/>
<layer number="16" name="Bottom" color="1" fill="1" visible="yes" active="yes"/>
<layer number="17" name="Pads" color="2" fill="1" visible="yes" active="yes"/>
<layer number="18" name="Vias" color="2" fill="1" visible="yes" active="yes"/>
<layer number="19" name="Unrouted" color="6" fill="1" visible="yes" active="yes"/>
<layer number="20" name="Dimension" color="15" fill="1" visible="yes" active="yes"/>
<layer number="21" name="tPlace" color="7" fill="1" visible="yes" active="yes"/>
<layer number="22" name="bPlace" color="7" fill="1" visible="yes" active="yes"/>
<layer number="23" name="tOrigins" color="15" fill="1" visible="yes" active="yes"/>
<layer number="24" name="bOrigins" color="15" fill="1" visible="yes" active="yes"/>
<layer number="25" name="tNames" color="7" fill="1" visible="yes" active="yes"/>
<layer number="26" name="bNames" color="7" fill="1" visible="yes" active="yes"/>
<layer number="27" name="tValues" color="7" fill="1" visible="yes" active="yes"/>
<layer number="28" name="bValues" color="7" fill="1" visible="yes" active="yes"/>
<layer number="29" name="tStop" color="7" fill="3" visible="yes" active="yes"/>
<layer number="30" name="bStop" color="7" fill="6" visible="yes" active="yes"/>
<layer number="31" name="tCream" color="7" fill="4" visible="yes" active="yes"/>
<layer number="32" name="bCream" color="7" fill="5" visible="yes" active="yes"/>
<layer number="33" name="tFinish" color="6" fill="3" visible="yes" active="yes"/>
<layer number="34" name="bFinish" color="6" fill="6" visible="yes" active="yes"/>
<layer number="35" name="tGlue" color="7" fill="4" visible="yes" active="yes"/>
<layer number="36" name="bGlue" color="7" fill="5" visible="yes" active="yes"/>
<layer number="37" name="tTest" color="7" fill="1" visible="yes" active="yes"/>
<layer number="38" name="bTest" color="7" fill="1" visible="yes" active="yes"/>
<layer number="39" name="tKeepout" color="4" fill="11" visible="yes" active="yes"/>
<layer number="40" name="bKeepout" color="1" fill="11" visible="yes" active="yes"/>
<layer number="41" name="tRestrict" color="4" fill="10" visible="yes" active="yes"/>
<layer number="42" name="bRestrict" color="1" fill="10" visible="yes" active="yes"/>
<layer number="43" name="vRestrict" color="2" fill="10" visible="yes" active="yes"/>
<layer number="44" name="Drills" color="7" fill="1" visible="yes" active="yes"/>
<layer number="45" name="Holes" color="7" fill="1" visible="yes" active="yes"/>
<layer number="46" name="Milling" color="3" fill="1" visible="yes" active="yes"/>
<layer number="47" name="Measures" color="7" fill="1" visible="yes" active="yes"/>
<layer number="48" name="Document" color="7" fill="1" visible="yes" active="yes"/>
<layer number="49" name="Reference" color="7" fill="1" visible="yes" active="yes"/>
<layer number="50" name="dxf" color="7" fill="1" visible="no" active="no"/>
<layer number="51" name="tDocu" color="7" fill="1" visible="yes" active="yes"/>
<layer number="52" name="bDocu" color="7" fill="1" visible="yes" active="yes"/>
<layer number="53" name="tGND_GNDA" color="7" fill="9" visible="no" active="no"/>
<layer number="54" name="bGND_GNDA" color="1" fill="9" visible="no" active="no"/>
<layer number="56" name="wert" color="7" fill="1" visible="no" active="no"/>
<layer number="57" name="tCAD" color="7" fill="1" visible="no" active="no"/>
<layer number="91" name="Nets" color="2" fill="1" visible="no" active="no"/>
<layer number="92" name="Busses" color="1" fill="1" visible="no" active="no"/>
<layer number="93" name="Pins" color="2" fill="1" visible="no" active="no"/>
<layer number="94" name="Symbols" color="4" fill="1" visible="no" active="no"/>
<layer number="95" name="Names" color="7" fill="1" visible="no" active="no"/>
<layer number="96" name="Values" color="7" fill="1" visible="no" active="no"/>
<layer number="97" name="Info" color="7" fill="1" visible="no" active="no"/>
<layer number="98" name="Guide" color="6" fill="1" visible="no" active="no"/>
<layer number="100" name="Muster" color="7" fill="1" visible="no" active="no"/>
<layer number="101" name="Patch_Top" color="12" fill="4" visible="yes" active="yes"/>
<layer number="102" name="Vscore" color="7" fill="1" visible="yes" active="yes"/>
<layer number="103" name="tMap" color="7" fill="1" visible="yes" active="yes"/>
<layer number="104" name="Name" color="16" fill="1" visible="yes" active="yes"/>
<layer number="105" name="tPlate" color="7" fill="1" visible="yes" active="yes"/>
<layer number="106" name="bPlate" color="7" fill="1" visible="yes" active="yes"/>
<layer number="107" name="Crop" color="7" fill="1" visible="yes" active="yes"/>
<layer number="108" name="fp8" color="7" fill="1" visible="yes" active="yes"/>
<layer number="109" name="fp9" color="7" fill="1" visible="yes" active="yes"/>
<layer number="110" name="fp0" color="7" fill="1" visible="yes" active="yes"/>
<layer number="111" name="LPC17xx" color="7" fill="1" visible="yes" active="yes"/>
<layer number="112" name="tSilk" color="7" fill="1" visible="yes" active="yes"/>
<layer number="116" name="Patch_BOT" color="9" fill="4" visible="yes" active="yes"/>
<layer number="118" name="Rect_Pads" color="7" fill="1" visible="yes" active="yes"/>
<layer number="120" name="Descript" color="7" fill="1" visible="yes" active="yes"/>
<layer number="121" name="_tsilk" color="7" fill="1" visible="yes" active="yes"/>
<layer number="122" name="_bsilk" color="7" fill="1" visible="yes" active="yes"/>
<layer number="123" name="tTestmark" color="7" fill="1" visible="yes" active="yes"/>
<layer number="124" name="bTestmark" color="7" fill="1" visible="yes" active="yes"/>
<layer number="125" name="_tNames" color="7" fill="1" visible="yes" active="yes"/>
<layer number="126" name="_bNames" color="7" fill="1" visible="yes" active="yes"/>
<layer number="127" name="_tValues" color="7" fill="1" visible="yes" active="yes"/>
<layer number="128" name="_bValues" color="7" fill="1" visible="yes" active="yes"/>
<layer number="131" name="tAdjust" color="7" fill="1" visible="yes" active="yes"/>
<layer number="132" name="bAdjust" color="7" fill="1" visible="yes" active="yes"/>
<layer number="144" name="Drill_legend" color="7" fill="1" visible="yes" active="yes"/>
<layer number="150" name="Notes" color="7" fill="1" visible="yes" active="yes"/>
<layer number="151" name="HeatSink" color="7" fill="1" visible="yes" active="yes"/>
<layer number="152" name="_bDocu" color="7" fill="1" visible="yes" active="yes"/>
<layer number="153" name="FabDoc1" color="7" fill="1" visible="yes" active="yes"/>
<layer number="154" name="FabDoc2" color="7" fill="1" visible="yes" active="yes"/>
<layer number="155" name="FabDoc3" color="7" fill="1" visible="yes" active="yes"/>
<layer number="199" name="Contour" color="7" fill="1" visible="yes" active="yes"/>
<layer number="200" name="200bmp" color="1" fill="10" visible="yes" active="yes"/>
<layer number="201" name="201bmp" color="2" fill="10" visible="yes" active="yes"/>
<layer number="202" name="202bmp" color="3" fill="10" visible="yes" active="yes"/>
<layer number="203" name="203bmp" color="4" fill="10" visible="yes" active="yes"/>
<layer number="204" name="204bmp" color="5" fill="10" visible="yes" active="yes"/>
<layer number="205" name="205bmp" color="6" fill="10" visible="yes" active="yes"/>
<layer number="206" name="206bmp" color="7" fill="10" visible="yes" active="yes"/>
<layer number="207" name="207bmp" color="8" fill="10" visible="yes" active="yes"/>
<layer number="208" name="208bmp" color="9" fill="10" visible="yes" active="yes"/>
<layer number="209" name="209bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="210" name="210bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="211" name="211bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="212" name="212bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="213" name="213bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="214" name="214bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="215" name="215bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="216" name="216bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="217" name="217bmp" color="18" fill="1" visible="no" active="no"/>
<layer number="218" name="218bmp" color="19" fill="1" visible="no" active="no"/>
<layer number="219" name="219bmp" color="20" fill="1" visible="no" active="no"/>
<layer number="220" name="220bmp" color="21" fill="1" visible="no" active="no"/>
<layer number="221" name="221bmp" color="22" fill="1" visible="no" active="no"/>
<layer number="222" name="222bmp" color="23" fill="1" visible="no" active="no"/>
<layer number="223" name="223bmp" color="24" fill="1" visible="no" active="no"/>
<layer number="224" name="224bmp" color="25" fill="1" visible="no" active="no"/>
<layer number="231" name="Eagle3D_PG1" color="7" fill="1" visible="yes" active="yes"/>
<layer number="232" name="Eagle3D_PG2" color="7" fill="1" visible="yes" active="yes"/>
<layer number="233" name="Eagle3D_PG3" color="7" fill="1" visible="yes" active="yes"/>
<layer number="247" name="wrappinf" color="7" fill="1" visible="yes" active="yes"/>
<layer number="248" name="PLCDoku" color="7" fill="1" visible="yes" active="yes"/>
<layer number="249" name="MillDoku" color="7" fill="1" visible="yes" active="yes"/>
<layer number="250" name="Descript" color="3" fill="1" visible="no" active="no"/>
<layer number="251" name="SMDround" color="12" fill="11" visible="no" active="no"/>
<layer number="252" name="BR-BS" color="7" fill="1" visible="yes" active="yes"/>
<layer number="253" name="BR-LS" color="7" fill="1" visible="yes" active="yes"/>
<layer number="254" name="cooling" color="7" fill="1" visible="yes" active="yes"/>
<layer number="255" name="ZchnBlatt" color="7" fill="1" visible="yes" active="yes"/>
</layers>
<board>
<plain>
<wire x1="14.224" y1="7.747" x2="8.382" y2="7.747" width="0.254" layer="41"/>
<wire x1="8.382" y1="7.747" x2="8.382" y2="13.716" width="0.254" layer="41"/>
<wire x1="8.382" y1="7.747" x2="8.382" y2="1.778" width="0.254" layer="41"/>
<wire x1="2.921" y1="1.397" x2="2.921" y2="14.097" width="0.254" layer="41"/>
<wire x1="14.224" y1="7.747" x2="14.224" y2="6.604" width="0.254" layer="41"/>
<wire x1="14.224" y1="5.842" x2="14.224" y2="1.778" width="0.254" layer="41"/>
<wire x1="14.224" y1="7.747" x2="14.224" y2="12.192" width="0.254" layer="41"/>
</plain>
<libraries>
<library name="thar">
<packages>
<package name="CARRIER_SMD2_3POL">
<smd name="GND" x="-6.985" y="0" dx="12.7" dy="4" layer="16" rot="R270"/>
<smd name="RX/TX" x="6.985" y="0" dx="12.7" dy="4" layer="16" rot="R270"/>
<wire x1="-8.5" y1="-6.5" x2="8.5" y2="-6.5" width="0" layer="20"/>
<wire x1="8.5" y1="-6.5" x2="10" y2="-5" width="0" layer="20" curve="90"/>
<wire x1="10" y1="-5" x2="10" y2="5" width="0" layer="20"/>
<wire x1="10" y1="5" x2="8.5" y2="6.5" width="0" layer="20" curve="90"/>
<wire x1="8.5" y1="6.5" x2="-8.5" y2="6.5" width="0" layer="20"/>
<wire x1="-8.5" y1="6.5" x2="-10" y2="5" width="0" layer="20" curve="90"/>
<wire x1="-10" y1="5" x2="-10" y2="-5" width="0" layer="20"/>
<wire x1="-10" y1="-5" x2="-8.5" y2="-6.5" width="0" layer="20" curve="90"/>
<smd name="RST" x="-9.4615" y="0.8255" dx="1.016" dy="1.016" layer="1" rot="R90"/>
<smd name="TST" x="-9.4615" y="-1.7145" dx="1.016" dy="1.016" layer="1" rot="R90"/>
<wire x1="-9" y1="6" x2="-9" y2="-6" width="0.127" layer="48"/>
<wire x1="9" y1="6" x2="9" y2="-6" width="0.127" layer="48"/>
<smd name="VCC''" x="-9.4615" y="-4.2545" dx="1.016" dy="1.016" layer="1" rot="R90"/>
<smd name="VCC" x="0" y="0" dx="12.7" dy="4" layer="16" rot="R270"/>
</package>
<package name="603">
<wire x1="-0.432" y1="-0.356" x2="0.432" y2="-0.356" width="0.1524" layer="51"/>
<wire x1="0.432" y1="0.356" x2="-0.432" y2="0.356" width="0.1524" layer="51"/>
<smd name="1" x="-0.8255" y="0" dx="0.889" dy="1.016" layer="1"/>
<smd name="2" x="0.8255" y="0" dx="0.889" dy="1.016" layer="1"/>
<text x="-0.127" y="0.6985" size="0.254" layer="25" align="bottom-right">>NAME</text>
<text x="0.127" y="0.6985" size="0.254" layer="27">>VALUE</text>
<rectangle x1="0.4318" y1="-0.4318" x2="0.8382" y2="0.4318" layer="51"/>
<rectangle x1="-0.8382" y1="-0.4318" x2="-0.4318" y2="0.4318" layer="51"/>
<rectangle x1="-0.1999" y1="-0.4001" x2="0.1999" y2="0.4001" layer="35"/>
</package>
<package name="QFN32">
<wire x1="-2.46" y1="2.46" x2="-2.065" y2="2.46" width="0.075" layer="21"/>
<wire x1="-2.46" y1="2.46" x2="-2.46" y2="2.065" width="0.075" layer="21"/>
<wire x1="2.065" y1="2.46" x2="2.46" y2="2.46" width="0.075" layer="21"/>
<wire x1="2.46" y1="2.46" x2="2.46" y2="2.065" width="0.075" layer="21"/>
<wire x1="2.46" y1="-2.065" x2="2.46" y2="-2.46" width="0.075" layer="21"/>
<wire x1="2.46" y1="-2.46" x2="2.065" y2="-2.46" width="0.075" layer="21"/>
<wire x1="-2.065" y1="-2.46" x2="-2.46" y2="-2.46" width="0.075" layer="21"/>
<wire x1="-2.46" y1="-2.46" x2="-2.46" y2="-2.065" width="0.075" layer="21"/>
<circle x="-2.17" y="2.17" radius="0.113134375" width="0.075" layer="21"/>
<smd name="TP" x="0" y="0" dx="3.302" dy="3.302" layer="1"/>
<smd name="32" x="-1.75" y="2.375" dx="0.254" dy="0.762" layer="1" roundness="100"/>
<smd name="31" x="-1.25" y="2.5" dx="0.254" dy="0.508" layer="1" roundness="100"/>
<smd name="30" x="-0.75" y="2.375" dx="0.254" dy="0.762" layer="1" roundness="100"/>
<smd name="29" x="-0.25" y="2.375" dx="0.254" dy="0.762" layer="1" roundness="100"/>
<smd name="28" x="0.25" y="2.375" dx="0.254" dy="0.762" layer="1" roundness="100"/>
<smd name="27" x="0.75" y="2.375" dx="0.254" dy="0.762" layer="1" roundness="100"/>
<smd name="26" x="1.25" y="2.375" dx="0.254" dy="0.762" layer="1" roundness="100"/>
<smd name="25" x="1.75" y="2.375" dx="0.254" dy="0.762" layer="1" roundness="100"/>
<smd name="24" x="2.375" y="1.75" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R270"/>
<smd name="23" x="2.375" y="1.25" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R270"/>
<smd name="22" x="2.375" y="0.75" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R270"/>
<smd name="21" x="2.375" y="0.25" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R270"/>
<smd name="20" x="2.375" y="-0.25" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R270"/>
<smd name="19" x="2.375" y="-0.75" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R270"/>
<smd name="18" x="2.375" y="-1.25" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R270"/>
<smd name="17" x="2.375" y="-1.75" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R270"/>
<smd name="16" x="1.75" y="-2.375" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R180"/>
<smd name="15" x="1.25" y="-2.375" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R180"/>
<smd name="14" x="0.75" y="-2.375" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R180"/>
<smd name="13" x="0.25" y="-2.375" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R180"/>
<smd name="12" x="-0.25" y="-2.375" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R180"/>
<smd name="11" x="-0.75" y="-2.375" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R180"/>
<smd name="10" x="-1.25" y="-2.375" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R180"/>
<smd name="9" x="-1.75" y="-2.4375" dx="0.254" dy="0.635" layer="1" roundness="100" rot="R180"/>
<smd name="8" x="-2.375" y="-1.75" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R90"/>
<smd name="7" x="-2.375" y="-1.25" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R90"/>
<smd name="6" x="-2.375" y="-0.75" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R90"/>
<smd name="5" x="-2.375" y="-0.25" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R90"/>
<smd name="4" x="-2.375" y="0.25" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R90"/>
<smd name="3" x="-2.375" y="0.75" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R90"/>
<smd name="2" x="-2.375" y="1.25" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R90"/>
<smd name="1" x="-2.375" y="1.75" dx="0.254" dy="0.762" layer="1" roundness="100" rot="R90"/>
</package>
</packages>
</library>
<library name="testpad">
<description>Test Pins/Pads

Cream on SMD OFF.

new: Attribute TP_SIGNAL_NAME

<author>Created by librarian@cadsoft.de</author></description>
<packages>
<package name="TP06R">
<description>TEST PAD</description>
<smd name="TP" x="0" y="0" dx="0.6" dy="0.6" layer="1" roundness="100" cream="no"/>
<text x="-0.3" y="0.4001" size="1.27" layer="25">>NAME</text>
<text x="-0.254" y="-0.381" size="0.0254" layer="27">>VALUE</text>
<text x="0" y="-1.905" size="1" layer="37">>TP_SIGNAL_NAME</text>
</package>
</packages>
</library>
</libraries>
<attributes>
</attributes>
<variantdefs>
</variantdefs>
<classes>
<class number="0" name="default" width="0" drill="0">
</class>
</classes>
<designrules name="Bilex DRU *">
<description language="de">EAGLE Design Rules

The default Design Rules have been set to cover
a wide range of applications. Your particular design
may have different requirements, so please make the
necessary adjustments and save your customized
design rules under a new name.</description>
<param name="layerSetup" value="(1*16)"/>
<param name="mtCopper" value="0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm"/>
<param name="mtIsolate" value="1.5mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm"/>
<param name="mdWireWire" value="10mil"/>
<param name="mdWirePad" value="10mil"/>
<param name="mdWireVia" value="10mil"/>
<param name="mdPadPad" value="10mil"/>
<param name="mdPadVia" value="10mil"/>
<param name="mdViaVia" value="10mil"/>
<param name="mdSmdPad" value="10mil"/>
<param name="mdSmdVia" value="10mil"/>
<param name="mdSmdSmd" value="10mil"/>
<param name="mdViaViaSameLayer" value="8mil"/>
<param name="mnLayersViaInSmd" value="2"/>
<param name="mdCopperDimension" value="1mil"/>
<param name="mdDrill" value="8mil"/>
<param name="mdSmdStop" value="0mil"/>
<param name="msWidth" value="10mil"/>
<param name="msDrill" value="24mil"/>
<param name="msMicroVia" value="9.99mm"/>
<param name="msBlindViaRatio" value="0.5"/>
<param name="rvPadTop" value="0.25"/>
<param name="rvPadInner" value="0.25"/>
<param name="rvPadBottom" value="0.25"/>
<param name="rvViaOuter" value="0.25"/>
<param name="rvViaInner" value="0.25"/>
<param name="rvMicroViaOuter" value="0.25"/>
<param name="rvMicroViaInner" value="0.25"/>
<param name="rlMinPadTop" value="10mil"/>
<param name="rlMaxPadTop" value="20mil"/>
<param name="rlMinPadInner" value="10mil"/>
<param name="rlMaxPadInner" value="20mil"/>
<param name="rlMinPadBottom" value="10mil"/>
<param name="rlMaxPadBottom" value="20mil"/>
<param name="rlMinViaOuter" value="8mil"/>
<param name="rlMaxViaOuter" value="20mil"/>
<param name="rlMinViaInner" value="8mil"/>
<param name="rlMaxViaInner" value="20mil"/>
<param name="rlMinMicroViaOuter" value="4mil"/>
<param name="rlMaxMicroViaOuter" value="20mil"/>
<param name="rlMinMicroViaInner" value="4mil"/>
<param name="rlMaxMicroViaInner" value="20mil"/>
<param name="psTop" value="-1"/>
<param name="psBottom" value="-1"/>
<param name="psFirst" value="-1"/>
<param name="psElongationLong" value="100"/>
<param name="psElongationOffset" value="100"/>
<param name="mvStopFrame" value="1"/>
<param name="mvCreamFrame" value="0"/>
<param name="mlMinStopFrame" value="4mil"/>
<param name="mlMaxStopFrame" value="4mil"/>
<param name="mlMinCreamFrame" value="0mil"/>
<param name="mlMaxCreamFrame" value="0mil"/>
<param name="mlViaStopLimit" value="0mil"/>
<param name="srRoundness" value="1"/>
<param name="srMinRoundness" value="0mil"/>
<param name="srMaxRoundness" value="10mil"/>
<param name="slThermalIsolate" value="10mil"/>
<param name="slThermalsForVias" value="0"/>
<param name="dpMaxLengthDifference" value="10mm"/>
<param name="dpGapFactor" value="2.5"/>
<param name="checkGrid" value="0"/>
<param name="checkAngle" value="0"/>
<param name="checkFont" value="1"/>
<param name="checkRestrict" value="1"/>
<param name="useDiameter" value="13"/>
<param name="maxErrors" value="50"/>
</designrules>
<autorouter>
<pass name="Default">
<param name="RoutingGrid" value="50mil"/>
<param name="AutoGrid" value="1"/>
<param name="Efforts" value="0"/>
<param name="TopRouterVariant" value="1"/>
<param name="tpViaShape" value="round"/>
<param name="PrefDir.1" value="|"/>
<param name="PrefDir.2" value="0"/>
<param name="PrefDir.3" value="0"/>
<param name="PrefDir.4" value="0"/>
<param name="PrefDir.5" value="0"/>
<param name="PrefDir.6" value="0"/>
<param name="PrefDir.7" value="0"/>
<param name="PrefDir.8" value="0"/>
<param name="PrefDir.9" value="0"/>
<param name="PrefDir.10" value="0"/>
<param name="PrefDir.11" value="0"/>
<param name="PrefDir.12" value="0"/>
<param name="PrefDir.13" value="0"/>
<param name="PrefDir.14" value="0"/>
<param name="PrefDir.15" value="0"/>
<param name="PrefDir.16" value="-"/>
<param name="cfVia" value="8"/>
<param name="cfNonPref" value="5"/>
<param name="cfChangeDir" value="2"/>
<param name="cfOrthStep" value="2"/>
<param name="cfDiagStep" value="3"/>
<param name="cfExtdStep" value="0"/>
<param name="cfBonusStep" value="1"/>
<param name="cfMalusStep" value="1"/>
<param name="cfPadImpact" value="4"/>
<param name="cfSmdImpact" value="4"/>
<param name="cfBusImpact" value="0"/>
<param name="cfHugging" value="3"/>
<param name="cfAvoid" value="4"/>
<param name="cfPolygon" value="10"/>
<param name="cfBase.1" value="0"/>
<param name="cfBase.2" value="1"/>
<param name="cfBase.3" value="1"/>
<param name="cfBase.4" value="1"/>
<param name="cfBase.5" value="1"/>
<param name="cfBase.6" value="1"/>
<param name="cfBase.7" value="1"/>
<param name="cfBase.8" value="1"/>
<param name="cfBase.9" value="1"/>
<param name="cfBase.10" value="1"/>
<param name="cfBase.11" value="1"/>
<param name="cfBase.12" value="1"/>
<param name="cfBase.13" value="1"/>
<param name="cfBase.14" value="1"/>
<param name="cfBase.15" value="1"/>
<param name="cfBase.16" value="0"/>
<param name="mnVias" value="20"/>
<param name="mnSegments" value="9999"/>
<param name="mnExtdSteps" value="9999"/>
<param name="mnRipupLevel" value="10"/>
<param name="mnRipupSteps" value="100"/>
<param name="mnRipupTotal" value="100"/>
</pass>
<pass name="Follow-me" refer="Default" active="yes">
</pass>
<pass name="Busses" refer="Default" active="yes">
<param name="cfNonPref" value="4"/>
<param name="cfBusImpact" value="4"/>
<param name="cfHugging" value="0"/>
<param name="mnVias" value="0"/>
</pass>
<pass name="Route" refer="Default" active="yes">
</pass>
<pass name="Optimize1" refer="Default" active="yes">
<param name="cfVia" value="99"/>
<param name="cfExtdStep" value="10"/>
<param name="cfHugging" value="1"/>
<param name="mnExtdSteps" value="1"/>
<param name="mnRipupLevel" value="0"/>
</pass>
<pass name="Optimize2" refer="Optimize1" active="yes">
<param name="cfNonPref" value="0"/>
<param name="cfChangeDir" value="6"/>
<param name="cfExtdStep" value="0"/>
<param name="cfBonusStep" value="2"/>
<param name="cfMalusStep" value="2"/>
<param name="cfPadImpact" value="2"/>
<param name="cfSmdImpact" value="2"/>
<param name="cfHugging" value="0"/>
</pass>
<pass name="Optimize3" refer="Optimize2" active="yes">
<param name="cfChangeDir" value="8"/>
<param name="cfPadImpact" value="0"/>
<param name="cfSmdImpact" value="0"/>
</pass>
<pass name="Optimize4" refer="Optimize3" active="yes">
<param name="cfChangeDir" value="25"/>
</pass>
</autorouter>
<elements>
<element name="U$1" library="thar" package="CARRIER_SMD2_3POL" value="CARRIER_SMD2SMD2_3POL" x="11.75" y="7.75" locked="yes" rot="R180"/>
<element name="U$2" library="thar" package="603" value="10k" x="19.812" y="10.106" rot="R90"/>
<element name="C1" library="thar" package="603" value="100n" x="16.637" y="8.89" smashed="yes" rot="R180">
<attribute name="NAME" x="14.478" y="10.0425" size="0.254" layer="25" rot="R180" align="bottom-right"/>
<attribute name="VALUE" x="14.913" y="9.6615" size="0.254" layer="27" rot="R180"/>
</element>
<element name="U$10" library="thar" package="QFN32" value="MSP430G2553" x="17.653" y="5.28"/>
<element name="TP1" library="testpad" package="TP06R" value="TPTP06R" x="11.303" y="8.382" smashed="yes">
<attribute name="TP_SIGNAL_NAME" value="" x="11.303" y="6.477" size="1" layer="37"/>
<attribute name="VALUE" x="11.049" y="8.001" size="0.0254" layer="27"/>
</element>
<element name="TP2" library="testpad" package="TP06R" value="TPTP06R" x="11.303" y="7.112" smashed="yes">
<attribute name="TP_SIGNAL_NAME" value="" x="11.303" y="5.207" size="1" layer="37"/>
<attribute name="VALUE" x="11.049" y="6.731" size="0.0254" layer="27"/>
</element>
<element name="TP4" library="testpad" package="TP06R" value="TPTP06R" x="7.62" y="1.778" smashed="yes">
<attribute name="TP_SIGNAL_NAME" value="" x="7.62" y="-0.127" size="1" layer="37"/>
<attribute name="VALUE" x="7.366" y="1.397" size="0.0254" layer="27"/>
</element>
</elements>
<signals>
<signal name="N$9">
</signal>
<signal name="N$30">
</signal>
<signal name="N$31">
</signal>
<signal name="N$33">
</signal>
<signal name="N$91">
</signal>
<signal name="N$92">
</signal>
<signal name="N$111">
</signal>
<signal name="N$121">
</signal>
<signal name="N$122">
</signal>
<signal name="N$123">
</signal>
<signal name="N$124">
</signal>
<signal name="N$125">
</signal>
<signal name="N$126">
</signal>
<signal name="N$127">
</signal>
<signal name="N$129">
</signal>
<signal name="N$130">
</signal>
<signal name="N$8">
</signal>
<signal name="N$10">
</signal>
<signal name="N$3">
<wire x1="19.05" y1="8.455" x2="18.923" y2="8.582" width="0.254" layer="1"/>
<wire x1="18.923" y1="8.582" x2="18.923" y2="9.979" width="0.254" layer="1"/>
<contactref element="U$1" pad="TST"/>
<contactref element="U$10" pad="24"/>
<wire x1="19.05" y1="8.455" x2="19.685" y2="8.455" width="0.254" layer="1"/>
<wire x1="21.36" y1="9.13" x2="21.2115" y2="9.274" width="0.254" layer="1"/>
<wire x1="18.923" y1="9.979" x2="19.05" y2="10.106" width="0.254" layer="1"/>
<wire x1="19.05" y1="10.106" x2="20.574" y2="10.106" width="0.254" layer="1"/>
<wire x1="20.028" y1="7.03" x2="19.939" y2="7.03" width="0.254" layer="1"/>
<wire x1="19.939" y1="7.03" x2="19.939" y2="8.201" width="0.254" layer="1"/>
<wire x1="19.939" y1="8.201" x2="19.685" y2="8.455" width="0.254" layer="1"/>
<wire x1="21.2115" y1="9.274" x2="21.240203125" y2="9.3903" width="0.254" layer="1"/>
<wire x1="21.240203125" y1="9.3903" x2="21.25" y2="9.43" width="0.254" layer="1"/>
<wire x1="21.25" y1="9.43" x2="20.574" y2="10.106" width="0.254" layer="1"/>
<wire x1="21.2115" y1="9.4645" x2="21.2115" y2="9.419003125" width="0.254" layer="1"/>
<wire x1="21.2115" y1="9.419003125" x2="21.240203125" y2="9.3903" width="0.254" layer="1"/>
</signal>
<signal name="N$12">
<via x="6.096" y="13.462" extent="1-16" drill="0.8" shape="octagon"/>
<contactref element="U$1" pad="RX/TX"/>
<wire x1="5.908" y1="7.623" x2="6.096" y2="13.462" width="0.254" layer="16"/>
<contactref element="U$10" pad="1"/>
<wire x1="15.278" y1="7.03" x2="15.068" y2="7.03" width="0.254" layer="1"/>
<wire x1="15.068" y1="7.03" x2="14.986" y2="7.112" width="0.254" layer="1"/>
<wire x1="14.986" y1="7.112" x2="14.986" y2="11.938" width="0.254" layer="1"/>
<wire x1="14.986" y1="11.938" x2="14.478" y2="12.446" width="0.254" layer="1"/>
<wire x1="14.478" y1="12.446" x2="12.827" y2="12.446" width="0.254" layer="1"/>
<wire x1="12.827" y1="12.446" x2="12.192" y2="13.081" width="0.254" layer="1"/>
<wire x1="12.192" y1="13.081" x2="12.192" y2="13.97" width="0.254" layer="1"/>
<wire x1="12.192" y1="13.97" x2="6.223" y2="13.97" width="0.254" layer="1"/>
<wire x1="6.223" y1="13.97" x2="6.223" y2="13.462" width="0.254" layer="1"/>
<wire x1="6.223" y1="13.462" x2="6.096" y2="13.462" width="0.254" layer="1"/>
<wire x1="4.765" y1="7.75" x2="6.096" y2="7.75" width="0.4064" layer="16"/>
<wire x1="6.096" y1="7.75" x2="6.096" y2="13.462" width="0.4064" layer="16"/>
</signal>
<signal name="N$4">
<contactref element="U$1" pad="RST"/>
<wire x1="21.2115" y1="6.734" x2="21.25" y2="6.635" width="0.254" layer="1"/>
<contactref element="U$2" pad="1"/>
<contactref element="U$10" pad="23"/>
<wire x1="21.2115" y1="6.734" x2="21.2334125" y2="6.853525" width="0.254" layer="1"/>
<wire x1="21.2334125" y1="6.853525" x2="21.25" y2="6.944" width="0.254" layer="1"/>
<wire x1="21.25" y1="6.944" x2="20.828" y2="6.985" width="0.254" layer="1"/>
<wire x1="19.812" y1="9.2805" x2="19.812" y2="9.217" width="0.254" layer="1"/>
<wire x1="19.812" y1="9.217" x2="20.828" y2="8.201" width="0.254" layer="1"/>
<wire x1="20.828" y1="8.201" x2="20.828" y2="6.985" width="0.254" layer="1"/>
<wire x1="20.028" y1="6.53" x2="21.03" y2="6.53" width="0.254" layer="1"/>
<wire x1="21.03" y1="6.53" x2="21.2115" y2="6.734" width="0.254" layer="1"/>
<wire x1="21.2115" y1="6.9245" x2="21.2115" y2="6.8754375" width="0.254" layer="1"/>
<wire x1="21.2115" y1="6.8754375" x2="21.2334125" y2="6.853525" width="0.254" layer="1"/>
</signal>
<signal name="GND">
<contactref element="C1" pad="2"/>
<contactref element="C1" pad="2"/>
<contactref element="U$10" pad="27"/>
<contactref element="U$10" pad="28"/>
<contactref element="U$10" pad="TP"/>
<wire x1="18.403" y1="7.655" x2="17.903" y2="7.655" width="0.254" layer="1"/>
<wire x1="17.936528125" y1="6.625734375" x2="18.1781625" y2="5.5960125" width="0.254" layer="1"/>
<wire x1="18.1781625" y1="5.5960125" x2="18.23" y2="4.314" width="0.254" layer="1"/>
<wire x1="18.23" y1="4.314" x2="17.653" y2="5.28" width="0.254" layer="1"/>
<contactref element="U$10" pad="32"/>
<contactref element="U$10" pad="8"/>
<wire x1="15.278" y1="3.53" x2="15.776" y2="3.53" width="0.254" layer="1"/>
<wire x1="15.776" y1="3.53" x2="16.637" y2="4.391" width="0.254" layer="1"/>
<wire x1="16.637" y1="4.391" x2="16.764" y2="4.191" width="0.254" layer="1"/>
<wire x1="16.764" y1="4.191" x2="17.653" y2="5.28" width="0.254" layer="1"/>
<wire x1="15.903" y1="7.655" x2="15.903" y2="7.411" width="0.254" layer="1"/>
<wire x1="15.903" y1="7.411" x2="16.51" y2="6.804" width="0.254" layer="1"/>
<wire x1="17.91479375" y1="6.604" x2="17.936528125" y2="6.625734375" width="0.254" layer="1"/>
<wire x1="15.903" y1="7.655" x2="15.903" y2="8.61" width="0.254" layer="1"/>
<wire x1="15.903" y1="8.61" x2="15.875" y2="8.709" width="0.254" layer="1"/>
<wire x1="15.875" y1="8.709" x2="16.002" y2="8.6995" width="0.254" layer="1"/>
<wire x1="16.002" y1="8.6995" x2="15.8115" y2="8.89" width="0.254" layer="1"/>
<wire x1="17.903" y1="7.655" x2="17.903" y2="5.969" width="0.254" layer="1"/>
<wire x1="17.903" y1="5.969" x2="17.903" y2="5.671175" width="0.254" layer="1"/>
<wire x1="17.903" y1="5.671175" x2="18.1781625" y2="5.5960125" width="0.254" layer="1"/>
<wire x1="16.51" y1="6.804" x2="17.268" y2="6.604" width="0.254" layer="1"/>
<wire x1="17.268" y1="6.604" x2="17.903" y2="5.969" width="0.254" layer="1"/>
<wire x1="15.8115" y1="8.89" x2="15.8115" y2="8.763" width="0.254" layer="1"/>
<contactref element="U$1" pad="GND"/>
<wire x1="18.403" y1="7.655" x2="18.403" y2="11.164" width="0.254" layer="1"/>
<wire x1="18.403" y1="11.164" x2="19.685" y2="12.446" width="0.254" layer="1"/>
<via x="19.685" y="12.446" extent="1-16" drill="0.8" shape="octagon"/>
<wire x1="19.685" y1="12.446" x2="19.685" y2="7.815" width="0.254" layer="16"/>
<wire x1="19.685" y1="7.815" x2="19.75" y2="7.75" width="0.254" layer="16"/>
<wire x1="18.735" y1="7.75" x2="19.685" y2="7.75" width="0.4064" layer="16"/>
<wire x1="19.685" y1="7.75" x2="19.685" y2="12.446" width="0.4064" layer="16"/>
</signal>
<signal name="VCC">
<contactref element="U$1" pad="VCC''"/>
<contactref element="U$2" pad="2"/>
<contactref element="C1" pad="1"/>
<contactref element="C1" pad="1"/>
<contactref element="U$10" pad="29"/>
<contactref element="U$10" pad="30"/>
<wire x1="17.403" y1="7.655" x2="17.399" y2="7.655" width="0.254" layer="1"/>
<wire x1="17.399" y1="13.462" x2="17.399" y2="9.271" width="0.254" layer="1"/>
<wire x1="17.399" y1="9.271" x2="17.399" y2="7.655" width="0.254" layer="1"/>
<wire x1="17.653" y1="9.017" x2="17.5895" y2="9.271" width="0.254" layer="1"/>
<wire x1="17.5895" y1="9.271" x2="17.399" y2="9.271" width="0.254" layer="1"/>
<wire x1="17.399" y1="7.655" x2="16.903" y2="7.655" width="0.254" layer="1"/>
<wire x1="17.4625" y1="8.89" x2="17.5895" y2="9.271" width="0.254" layer="1"/>
<wire x1="21.25" y1="11.77" x2="21.2115" y2="11.814" width="0.254" layer="1"/>
<wire x1="19.812" y1="10.9315" x2="19.8755" y2="10.7315" width="0.254" layer="1"/>
<wire x1="19.8755" y1="10.7315" x2="20.955" y2="11.811" width="0.254" layer="1"/>
<wire x1="20.955" y1="11.811" x2="20.9545" y2="11.757" width="0.254" layer="1"/>
<wire x1="20.9545" y1="11.757" x2="21.2115" y2="11.814" width="0.254" layer="1"/>
<wire x1="21.3085" y1="12.2915" x2="21.4" y2="12.2" width="0.254" layer="1"/>
<wire x1="21.4" y1="12.2" x2="21.4" y2="12.0025" width="0.254" layer="1"/>
<wire x1="21.4" y1="12.0025" x2="21.2115" y2="11.814" width="0.254" layer="1"/>
<wire x1="21.2115" y1="12.1945" x2="21.3085" y2="12.2915" width="0.254" layer="1"/>
<contactref element="U$1" pad="VCC"/>
<wire x1="21.2115" y1="12.0045" x2="21.2115" y2="12.4435" width="0.254" layer="1"/>
<wire x1="21.2115" y1="12.4435" x2="20.193" y2="13.462" width="0.254" layer="1"/>
<wire x1="17.399" y1="13.462" x2="20.193" y2="13.462" width="0.254" layer="1"/>
<via x="13.208" y="13.462" extent="1-16" drill="0.8" shape="octagon"/>
<wire x1="13.208" y1="13.462" x2="17.399" y2="13.462" width="0.254" layer="1"/>
<wire x1="11.75" y1="7.75" x2="13.208" y2="7.75" width="0.4064" layer="16"/>
<wire x1="13.208" y1="7.75" x2="13.208" y2="13.462" width="0.4064" layer="16"/>
<wire x1="21.2115" y1="12.0045" x2="21.2115" y2="12.1945" width="0" layer="19" extent="1-1"/>
</signal>
<signal name="N$1">
</signal>
<signal name="N$15">
</signal>
<signal name="N$2">
<contactref element="U$10" pad="2"/>
<contactref element="TP1" pad="TP"/>
<wire x1="15.278" y1="6.53" x2="14.679" y2="6.53" width="0.254" layer="1"/>
<wire x1="14.679" y1="6.53" x2="14.478" y2="6.731" width="0.254" layer="1"/>
<wire x1="14.478" y1="6.731" x2="14.478" y2="8.001" width="0.254" layer="1"/>
<polygon width="0.254" layer="1" thermals="no">
<vertex x="8.509" y="13.716"/>
<vertex x="14.097" y="13.716"/>
<vertex x="14.097" y="7.874"/>
<vertex x="8.509" y="7.874"/>
</polygon>
<wire x1="14.478" y1="8.001" x2="11.557" y2="8.001" width="0.254" layer="1"/>
<wire x1="11.557" y1="8.001" x2="11.303" y2="8.382" width="0.254" layer="1"/>
</signal>
<signal name="N$5">
<contactref element="U$10" pad="3"/>
<contactref element="TP2" pad="TP"/>
<wire x1="15.278" y1="6.03" x2="14.417" y2="6.03" width="0.254" layer="1"/>
<wire x1="14.417" y1="6.03" x2="13.97" y2="6.477" width="0.254" layer="1"/>
<wire x1="13.97" y1="6.477" x2="13.97" y2="7.112" width="0.254" layer="1"/>
<wire x1="13.97" y1="7.112" x2="11.303" y2="7.112" width="0.254" layer="1"/>
<polygon width="0.254" layer="1" thermals="no">
<vertex x="8.509" y="7.62"/>
<vertex x="14.097" y="7.62"/>
<vertex x="14.097" y="1.905"/>
<vertex x="8.509" y="1.905"/>
</polygon>
</signal>
<signal name="N$6">
<contactref element="U$10" pad="7"/>
<contactref element="TP4" pad="TP"/>
<wire x1="15.278" y1="4.03" x2="14.698" y2="4.03" width="0.254" layer="1"/>
<wire x1="14.698" y1="4.03" x2="14.478" y2="3.81" width="0.254" layer="1"/>
<wire x1="14.478" y1="3.81" x2="14.478" y2="1.524" width="0.254" layer="1"/>
<wire x1="14.478" y1="1.524" x2="7.874" y2="1.524" width="0.254" layer="1"/>
<wire x1="7.874" y1="1.524" x2="7.62" y2="1.778" width="0.254" layer="1"/>
<polygon width="0.254" layer="1" thermals="no">
<vertex x="3.048" y="14.097"/>
<vertex x="8.255" y="14.097"/>
<vertex x="8.255" y="1.397"/>
<vertex x="3.048" y="1.397"/>
</polygon>
</signal>
</signals>
<errors>
<approved hash="1,20,1883ea63e9721b92"/>
<approved hash="1,20,98828a6289739b93"/>
<approved hash="18,29,7d17f251816e75d7"/>
<approved hash="18,29,7c13ebd588e87455"/>
<approved hash="18,29,7de8ea4c896175be"/>
<approved hash="6,1,264930e3214fc7b3"/>
<approved hash="6,1,207b6734f0347d5f"/>
<approved hash="5,1,4544b36eb5d02684"/>
<approved hash="5,1,4544b36541d91ee8"/>
<approved hash="5,1,f6e620c40a789cd0"/>
<approved hash="5,1,149b2256ea996042"/>
<approved hash="5,1,60bb99ac766c6e85"/>
<approved hash="5,1,f47722550a7e9e41"/>
<approved hash="5,1,2b281de5eaa95fcd"/>
<approved hash="5,1,60bb99a9a8252169"/>
<approved hash="5,1,f8a22e800a709294"/>
<approved hash="5,1,1edf2812ea996a06"/>
<approved hash="5,1,92bb60207abc4adc"/>
<approved hash="5,1,60bb99ac766c6e85"/>
<approved hash="5,1,2ba7239833df1715"/>
<approved hash="5,1,2538239633df1984"/>
<approved hash="5,1,2e85239833db1233"/>
<approved hash="5,1,2816239a33db14a2"/>
<approved hash="5,1,20c9239033db1c77"/>
<approved hash="5,1,225a239233db1ee6"/>
<approved hash="5,1,92bb721d4862ccfe"/>
<approved hash="5,1,1deb239033e72169"/>
<approved hash="5,1,60bb99af48ec7985"/>
<approved hash="5,1,f83006283ea1acf5"/>
<approved hash="5,1,9175f83020f1169b"/>
<approved hash="5,1,e0902e3023352fe5"/>
<approved hash="5,1,1fdcafb7251d316e"/>
<approved hash="5,1,40c3317559775bdd"/>
<approved hash="5,1,d35688d736a0c379"/>
<approved hash="5,1,1eece91dffc5d884"/>
<approved hash="5,1,b7c1c6755b7759df"/>
<approved hash="5,1,b519822fc2f1b32f"/>
<approved hash="5,1,b551ee1188deb32f"/>
<approved hash="5,1,d919822fc2c3e7c8"/>
<approved hash="5,1,26c4577559775bda"/>
<approved hash="5,1,093eb3c79bf20dfd"/>
<approved hash="5,1,b551eee7b4f5917e"/>
<approved hash="5,1,8e15d11758d572eb"/>
<approved hash="5,1,fb14a02fd2c3f7c5"/>
<approved hash="5,1,95cae475577755d4"/>
<approved hash="5,1,04c97575517753d7"/>
<approved hash="5,1,ac18f31750d57ae6"/>
<approved hash="5,1,8bcffa75537751d1"/>
<approved hash="5,1,231e7c1752d578e0"/>
<approved hash="5,1,7abf551c2edb148b"/>
<approved hash="5,1,7c2c551e2edb121a"/>
<approved hash="5,1,790e551e2edf173c"/>
<approved hash="5,1,70f355142edb1ecf"/>
<approved hash="5,1,4f4255162ee72140"/>
<approved hash="5,1,2bd3c06c35ecf92d"/>
<approved hash="5,1,2bd3c06f86afdead"/>
<approved hash="5,1,726055162edb1c5e"/>
<approved hash="5,1,67224f63b2096300"/>
<approved hash="5,1,779155102edf19ad"/>
<approved hash="5,1,937a8ed079d95c8f"/>
<approved hash="5,1,5666e3988ed1c4a3"/>
<approved hash="5,1,937aafafbd83dead"/>
<approved hash="5,1,f2d9aa1b2a7672b4"/>
<approved hash="5,1,b3a95525b1eb65b4"/>
<approved hash="5,1,a86e093ae9553cd4"/>
<approved hash="5,1,03a77119b6d3cec7"/>
<approved hash="5,1,0b138b10aa1b2a18"/>
<approved hash="5,1,35b82fdfcf79e1f9"/>
<approved hash="5,1,d0f38f31f05caf9e"/>
<approved hash="5,1,920072772bb8b92e"/>
<approved hash="5,1,acdfecdc8524c527"/>
<approved hash="5,1,5c77abbdd98614b1"/>
<approved hash="5,1,ceeeb852471131ef"/>
<approved hash="5,1,388e4f205b97164d"/>
<approved hash="5,1,45503379c859ba28"/>
<approved hash="5,1,21c9d771a4715e01"/>
<approved hash="5,1,cd6197312440f219"/>
<approved hash="19,16,e8d986abfeb990cb"/>
<approved hash="19,16,cda43f5627bfd54d"/>
<approved hash="19,16,ac98eeeaeedaaca8"/>
</errors>
</board>
</drawing>
</eagle>

license: MIT

repository: JanThar/WearkitTen

license_type: permissive

repo_name: JanThar/WearkitTen

branch_name: refs/heads/master

extension: brd


text:
package logstream

import (
	"errors"
	"io"
	"os"
	"sync"

	"github.com/fxamacker/cbor/v2"
	"github.com/maxpert/marmot/cfg"
)

var ErrNotInitialized = errors.New("not initialized")

type replicationState struct {
	seq  map[string]uint64
	lock *sync.RWMutex
	fl   *os.File
}

func (r *replicationState) init() error {
	fl, err := os.OpenFile(cfg.Config.SeqMapPath, os.O_RDWR|os.O_CREATE|os.O_SYNC, 0666)
	if err != nil {
		return err
	}

	r.seq = make(map[string]uint64)
	r.lock = &sync.RWMutex{}
	r.fl = fl

	idx, err := fl.Seek(0, io.SeekEnd)
	if err != nil {
		return err
	}

	if idx < 1 {
		return nil
	}

	_, err = fl.Seek(0, io.SeekStart)
	if err != nil {
		return err
	}

	return cbor.NewDecoder(fl).Decode(&r.seq)
}

func (r *replicationState) save(streamName string, seq uint64) (uint64, error) {
	r.lock.Lock()
	defer r.lock.Unlock()
	if r.fl == nil {
		return 0, ErrNotInitialized
	}

	if old, found := r.seq[streamName]; found && seq <= old {
		return old, nil
	}

	_, err := r.fl.Seek(0, io.SeekStart)
	if err != nil {
		return 0, err
	}
	defer r.fl.Sync()

	r.seq[streamName] = seq
	err = cbor.NewEncoder(r.fl).Encode(r.seq)
	if err != nil {
		return 0, err
	}

	return seq, nil
}

func (r *replicationState) get(streamName string) uint64 {
	r.lock.RLock()
	defer r.lock.RUnlock()

	if old, found := r.seq[streamName]; found {
		return old
	}

	return 0
}

repository: maxpert/marmot

repo_name: maxpert/marmot

gha_license_id: MIT

gha_language: Go

extension: go


text:
HOMEPAGE = "http://xournal.sf.net/"
DESCRIPTION = "Xournal is an application for notetaking, sketching, keeping a journal using a stylus."
DEPENDS = "gtk+ libgnomecanvas libgnomeprintui"
# For pdftopnm:
RDEPENDS_${PN} = "poppler"
SECTION = "x11"
LICENSE = "GPL"
PR = "r1"

SRC_URI = "http://xournal.sourceforge.net/xournal-${PV}.tar.gz \
          "

inherit autotools pkgconfig

SRC_URI[md5sum] = "b3d352d08e71606383c31da5790b8d60"
SRC_URI[sha256sum] = "dff617ca33dc263caecb6afc5d42c109166ef2a1c0fe0afa070ff6691ea0e8d7"

repository: overo/overo-oe-natty

repo_name: overo/overo-oe-natty

branch_name: HEAD

extension: bb


text:
package ioutilhelper

import (
	"io"
	"os"
	"sort"
)

// ReadDirNames reads the directory named by dirName and returns list of directory entries.
// Result slice will be sorted if arrange is set to true.
func ReadDirNames(dirName string, arrange bool) ([]string, error) {
	f, err := os.Open(dirName)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	names, err := f.Readdirnames(-1)
	if err != nil {
		return nil, err
	}

	if arrange {
		sort.Strings(names)
	}
	return names, nil
}

// IsDirEmpty checks if directory named by dirName is empty (has no child).
func IsDirEmpty(dirName string) (bool, error) {
	f, err := os.Open(dirName)
	if err != nil {
		return false, err
	}
	defer f.Close()

	_, err = f.Readdir(1)
	if err == io.EOF {
		return true, nil
	}
	return false, err
}

repository: apaxa-io/iohelper

repo_name: apaxa-io/iohelper


text:
//Copyright (c) 2017 Phil

package apollo

import (
	"fmt"
	"net"
	"net/url"
)

func getLocalIP() string {
	addrs, err := net.InterfaceAddrs()
	if err != nil {
		return ""
	}
	for _, a := range addrs {
		if ip4 := toIP4(a); ip4 != nil {
			return ip4.String()
		}
	}
	return ""
}

func toIP4(addr net.Addr) net.IP {
	if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
		return ipnet.IP.To4()
	}
	return nil
}

func notificationURL(conf *Conf, notifications string) string {
	return fmt.Sprintf("http://%s/notifications/v2?appId=%s&cluster=%s&notifications=%s",
		conf.IP,
		url.QueryEscape(conf.AppID),
		url.QueryEscape(conf.Cluster),
		url.QueryEscape(notifications))
}

func configURL(conf *Conf, namespace string, releaseKey string) string {
	return fmt.Sprintf("http://%s/configs/%s/%s/%s?releaseKey=%s&ip=%s",
		conf.IP,
		url.QueryEscape(conf.AppID),
		url.QueryEscape(conf.Cluster),
		url.QueryEscape(namespace),
		releaseKey,
		getLocalIP())
}

repository: go-apollo/apollo

repo_name: go-apollo/apollo


text:
// Package integration contains AIS integration tests.
/*
 * Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
 */
package integration

import (
	"flag"
	"fmt"
	"math/rand"
	"os"
	"strconv"
	"testing"
	"time"

	"github.com/NVIDIA/aistore/api"
	"github.com/NVIDIA/aistore/cmn"
	"github.com/NVIDIA/aistore/devtools/tutils"
)

var (
	proxyURL   string
	baseParams api.BaseParams
)

func setBucket() (bck cmn.Bck, err error) {
	var (
		bucket   = os.Getenv("BUCKET")
		provider = os.Getenv("PROVIDER")
	)
	if bucket == "" {
		bucket = cmn.RandString(7)
		tutils.Logf("Using BUCKET=%q\n", bucket)
	}
	bck, _, err = cmn.ParseBckObjectURI(bucket)
	if err != nil {
		return bck, fmt.Errorf("failed to parse 'BUCKET' env variable, err: %v", err)
	}
	if provider != "" {
		if bck.Provider != "" && bck.Provider != provider {
			return bck, fmt.Errorf("provider is set for both 'BUCKET' (%q) and 'PROVIDER' (%q) env variables",
				bck, provider)
		}
		if err = cmn.ValidateProvider(provider); err != nil {
			return bck, fmt.Errorf("%v (make sure 'PROVIDER' env variable is properly set)", err)
		}
		bck.Provider = provider
	}
	return bck, nil
}

func waitForCluster() error {
	var (
		err        error
		proxyCnt   int
		targetCnt  int
		retryCount = 5
		sleep      = 5 * time.Second
	)
	pc := os.Getenv(cmn.EnvVars.NumProxy)
	tc := os.Getenv(cmn.EnvVars.NumTarget)
	if pc != "" || tc != "" {
		proxyCnt, err = strconv.Atoi(pc)
		if err != nil {
			return fmt.Errorf("error EnvVars: %s. err: %v", cmn.EnvVars.NumProxy, err)
		}
		targetCnt, err = strconv.Atoi(tc)
		if err != nil {
			return fmt.Errorf("error EnvVars: %s. err: %v", cmn.EnvVars.NumTarget, err)
		}
	}

	tutils.Logln("Waiting for clustermap init...")
	_, err = tutils.WaitForClusterState(tutils.GetPrimaryURL(), "startup", -1, proxyCnt, targetCnt)
	if err != nil {
		return fmt.Errorf("error waiting for cluster startup, err: %v", err)
	}

	tutils.Logln("Waiting for primary proxy health check...")
	retry := 0
	for {
		if retry > 0 {
			tutils.Logf("Pinging primary for health (#%d)...\n", retry+1)
		}
		err = api.Health(tutils.BaseAPIParams(tutils.GetPrimaryURL()))
		if err == nil {
			time.Sleep(time.Second)
			break
		}
		if retry == retryCount {
			return fmt.Errorf("error waiting for cluster startup, err: %v", err)
		}
		retry++
		time.Sleep(sleep)
	}
	tutils.Logln("Cluster is ready")
	time.Sleep(2 * time.Second)
	return nil
}

func initTestEnv() {
	tutils.InitLocalCluster()
	proxyURL = tutils.RandomProxyURL()
	baseParams = tutils.BaseAPIParams(proxyURL)
	initEC()
}

func TestMain(m *testing.M) {
	flag.Parse()

	initTestEnv()
	var err error
	if cliBck, err = setBucket(); err == nil {
		err = waitForCluster()
	}

	if err != nil {
		tutils.Logln("FAIL: " + err.Error())
		os.Exit(1)
	}

	rand.Seed(time.Now().UnixNano())
	m.Run()
}


text:
using MediaLibrary.Models;
using System.Threading.Tasks;

namespace MediaLibrary.Services
{
    public interface IModerationService
    {
        Task<ModerationResultsViewModel> IsContentAllowed(string objectLocation);
    }
}

repository: aws-samples/aws-net-guides

repo_name: aws-samples/aws-net-guides

gha_language: JavaScript

extension: cs


text:
package reconcilers_test

import (
	"context"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"k8s.io/apimachinery/pkg/types"

	api "sigs.k8s.io/multi-tenancy/incubator/hnc/api/v1alpha2"
	"sigs.k8s.io/multi-tenancy/incubator/hnc/internal/config"
)

var _ = Describe("Anchor", func() {
	ctx := context.Background()

	var (
		fooName string
		barName string
	)

	BeforeEach(func() {
		fooName = createNS(ctx, "foo")
		barName = createNSName("bar")
		config.ExcludedNamespaces = nil
	})

	It("should create an subnamespace and update the hierarchy according to the anchor", func() {
		// Create 'bar' anchor in 'foo' namespace.
		foo_anchor_bar := newAnchor(barName, fooName)
		updateAnchor(ctx, foo_anchor_bar)

		// It should create the namespace 'bar' with 'foo' in the subnamespace-of annotation.
		Eventually(func() string {
			return getNamespace(ctx, barName).GetAnnotations()[api.SubnamespaceOf]
		}).Should(Equal(fooName))

		// It should set the subnamespace "bar" as a child of the parent "foo".
		Eventually(func() []string {
			fooHier := getHierarchy(ctx, fooName)
			return fooHier.Status.Children
		}).Should(Equal([]string{barName}))

		// It should set the parent namespace "foo" as the parent of "bar".
		Eventually(func() string {
			barHier := getHierarchy(ctx, barName)
			return barHier.Spec.Parent
		}).Should(Equal(fooName))

		// It should set the anchor.status.state to Ok if the above sub-tests all pass.
		Eventually(getAnchorState(ctx, fooName, barName)).Should(Equal(api.Ok))
	})

	It("should remove the anchor in an excluded namespace", func() {
		config.ExcludedNamespaces = map[string]bool{"kube-system": true}
		kube_system_anchor_bar := newAnchor(barName, "kube-system")
		updateAnchor(ctx, kube_system_anchor_bar)
		Eventually(canGetAnchor(ctx, barName, "kube-system")).Should(Equal(false))
	})

	It("should set the anchor.status.state to Forbidden if the subnamespace is an excluded namespace", func() {
		config.ExcludedNamespaces = map[string]bool{"kube-system": true}
		foo_anchor_kube_system := newAnchor("kube-system", fooName)
		updateAnchor(ctx, foo_anchor_kube_system)
		Eventually(getAnchorState(ctx, fooName, "kube-system")).Should(Equal(api.Forbidden))
	})

	It("should set the anchor.status.state to Conflict if a namespace of the same name already exists", func() {
		// Create "baz" namespace.
		bazName := createNS(ctx, "baz")
		// Create an anchor still with the same name "baz" in "foo" namespace.
		foo_anchor_baz := newAnchor(bazName, fooName)
		updateAnchor(ctx, foo_anchor_baz)
		Eventually(getAnchorState(ctx, fooName, bazName)).Should(Equal(api.Conflict))
	})

	It("should always set the owner as the parent if otherwise", func() {
		// Create "bar" anchor in "foo" namespace.
		foo_anchor_bar := newAnchor(barName, fooName)
		updateAnchor(ctx, foo_anchor_bar)
		Eventually(func() string {
			barHier := getHierarchy(ctx, barName)
			return barHier.Spec.Parent
		}).Should(Equal(fooName))

		// Change the bar's parent. Additionally change another field to reflect the
		// update of the HC instance (hc.Spec.AllowCascadingDeletion).
		Eventually(func() error {
			barHier := getHierarchy(ctx, barName)
			barHier.Spec.Parent = "other"
			barHier.Spec.AllowCascadingDeletion = true
			return tryUpdateHierarchy(ctx, barHier) // can fail if made too quickly
		}).Should(Succeed())

		// The parent of 'bar' should be set back to 'foo' after reconciliation.
		Eventually(func() bool {
			barHier := getHierarchy(ctx, barName)
			return barHier.Spec.AllowCascadingDeletion
		}).Should(Equal(true))
		Eventually(func() string {
			barHier := getHierarchy(ctx, barName)
			return barHier.Spec.Parent
		}).Should(Equal(fooName))
	})
})

func getAnchorState(ctx context.Context, pnm, nm string) func() api.SubnamespaceAnchorState {
	return func() api.SubnamespaceAnchorState {
		return getAnchor(ctx, pnm, nm).Status.State
	}
}

func newAnchor(anm, nm string) *api.SubnamespaceAnchor {
	anchor := &api.SubnamespaceAnchor{}
	anchor.ObjectMeta.Namespace = nm
	anchor.ObjectMeta.Name = anm
	return anchor
}

func getAnchor(ctx context.Context, pnm, nm string) *api.SubnamespaceAnchor {
	return getAnchorWithOffset(1, ctx, pnm, nm)
}

func getAnchorWithOffset(offset int, ctx context.Context, pnm, nm string) *api.SubnamespaceAnchor {
	nsn := types.NamespacedName{Name: nm, Namespace: pnm}
	anchor := &api.SubnamespaceAnchor{}
	EventuallyWithOffset(offset+1, func() error {
		return k8sClient.Get(ctx, nsn, anchor)
	}).Should(Succeed())
	return anchor
}

func canGetAnchor(ctx context.Context, pnm, nm string) func() bool {
	return func() bool {
		nsn := types.NamespacedName{Name: nm, Namespace: pnm}
		anchor := &api.SubnamespaceAnchor{}
		if err := k8sClient.Get(ctx, nsn, anchor); err != nil {
			return false
		}
		return true
	}
}

func updateAnchor(ctx context.Context, anchor *api.SubnamespaceAnchor) {
	if anchor.CreationTimestamp.IsZero() {
		ExpectWithOffset(1, k8sClient.Create(ctx, anchor)).Should(Succeed())
	} else {
		ExpectWithOffset(1, k8sClient.Update(ctx, anchor)).Should(Succeed())
	}
}

repository: Fei-Guo/multi-tenancy

repo_name: Fei-Guo/multi-tenancy


text:
import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root',
})
export class IntegrationTestService {
  public getSomeValue() {
    return 'real value from service';
  }

  constructor() {
    //
  }
}

repository: distante/ng-mockito

repo_name: distante/ng-mockito

branch_name: refs/heads/main

extension: ts


text:
export default interface SidebarItemProps {
  name: string
  shouldExpand: boolean
  categories: SidebarItemProps[]
  showIcon?: boolean
  interval: number
  active?: boolean,
  canNotBeActivated?: boolean
  clickOnlyToExpand: boolean
  classes?: any
  onExpandIconClick?: Function
  onNameClick?: Function
  onClick?: Function
  mountedCallbackComponent?: Function
  willUnmountCallbackComponent?: Function
}

repository: Terry-Su/TSBlogBuilder

repo_name: Terry-Su/TSBlogBuilder


text:
SUMMARY = "Audio decoder for MPEG-1 Layer 1/2/3"
DESCRIPTION = "The core of mpg123 is an MPEG-1 Layer 1/2/3 decoding library, which can be used by other programs. \
mpg123 also comes with a command-line tool which can playback using ALSA, PulseAudio, OSS, and several other APIs, \
and also can write the decoded audio to WAV."
HOMEPAGE = "http://mpg123.de/"
BUGTRACKER = "http://sourceforge.net/p/mpg123/bugs/"
SECTION = "multimedia"

LICENSE = "LGPLv2.1"
LICENSE_FLAGS = "commercial"
LIC_FILES_CHKSUM = "file://COPYING;md5=a7aa23a2b646eca38ad4eeb7a853761c"

SRC_URI = "${SOURCEFORGE_MIRROR}/mpg123/mpg123/${PV}/mpg123-${PV}.tar.bz2"

SRC_URI[md5sum] = "f734f9e2982f398a1c919475fc0b3798"
SRC_URI[sha256sum] = "b6b1aef887835f83ac3d4acb5701ae619041fc60d76548ad779a409080338df7"

S = "${WORKDIR}/mpg123-${PV}"

inherit autotools pkgconfig

EXTRA_OECONF = " \
    --enable-shared \
    ${@bb.utils.contains('TUNE_FEATURES', 'neon', '--with-cpu=neon', '', d)} \
    ${@bb.utils.contains('TUNE_FEATURES', 'altivec', '--with-cpu=altivec', '', d)} \
    ${@bb.utils.contains('DISTRO_FEATURES', 'alsa', '--with-default-audio=alsa', '', d)} \
    ${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', '--with-default-audio=pulse', '', d)} \
"

repository: linkessence/Galileo

repo_name: linkessence/Galileo


text:
package utils

import (
	"encoding/json"

	"github.com/bitly/go-simplejson"
)

func NewJsonFromAny(data interface{}) *simplejson.Json {
	dataByte, _ := json.Marshal(data)
	dataJson, _ := simplejson.NewJson(dataByte)
	return dataJson
}

func NewRawJsonFromAny(data interface{}) []byte {
	dataByte, _ := json.Marshal(data)
	dataJson, _ := simplejson.NewJson(dataByte)
	dataJsonRaw, _ := dataJson.MarshalJSON()
	return dataJsonRaw
}


text:
/*
 * @adonisjs/ace
 *
 * (c) Harminder Virk <virk@adonisjs.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

import { Application } from '@adonisjs/application'

import { Kernel } from '../src/Kernel'
import { args } from '../src/Decorators/args'
import { flags } from '../src/Decorators/flags'
import { BaseCommand } from '../src/BaseCommand'
import { handleError } from '../src/utils/handleError'

class Greet extends BaseCommand {
  public static commandName = 'greet'
  public static description = 'Greet a user with their name'
  public static aliases = ['gr', 'sayhi']

  @args.string({ description: 'The name of the person you want to greet' })
  public name: string

  @args.string()
  public age?: string

  @args.spread()
  public files: string[]

  @flags.string({
    description: 'The environment to use to specialize certain commands',
    alias: 'e',
  })
  public env: 'development' | 'production'

  @flags.string({
    description: 'The main HTML file that will be requested',
  })
  public entrypoint: string

  @flags.numArray({ description: 'HTML fragments loaded on demand', alias: 'f' })
  public fragment: string

  public async prepare() {
    if (this.env === undefined) {
      this.env = await this.prompt.choice('Select one of the given environments', [
        'development',
        'production',
      ])
    }

    if (this.entrypoint === undefined) {
      this.entrypoint = await this.prompt.ask('Define entrypoint as we detected multiple?')
    }
  }

  public async run() {
    this.logger.success('Operation successful')
    this.logger.error('Unable to acquire lock')
    this.logger.info('Hello')
    this.logger.action('write').succeeded('Release notes')
    this.logger.action('write').skipped('Release notes')
    this.logger.info('Please get it done')
  }
}

class MakeController extends BaseCommand {
  public static commandName = 'make:controller'
  public static description = 'Create a HTTP controller'

  public async run() {}
}

class MakeModel extends BaseCommand {
  public static commandName = 'make:model'
  public static description = 'Create database model'

  public async run() {
    console.log(process.env.NODE_ENV)
  }
}

const app = new Application(__dirname, 'web', {})
const kernel = new Kernel(app)
kernel.register([Greet, MakeController, MakeModel])

kernel.flag(
  'help',
  (value, _, command) => {
    if (!value) {
      return
    }

    kernel.printHelp(command)
    process.exit(0)
  },
  { type: 'boolean' }
)

kernel.flag(
  'env',
  (value) => {
    process.env.NODE_ENV = value
  },
  { type: 'string' }
)

kernel.onExit(() => {
  if (kernel.error) {
    handleError(kernel.error)
  }
  process.exit(kernel.exitCode)
})

kernel.handle(process.argv.splice(2))

repository: adonisjs/ace

repo_name: adonisjs/ace

branch_name: refs/heads/develop

gha_language: TypeScript