Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/GenCode128/Code128Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private int[] StringToCode128(string asciiData)
var csa1 = asciiBytes.Length > 0
? Code128Code.CodesetAllowedForChar(asciiBytes[0])
: Code128Code.CodeSetAllowed.CodeAorB;
var csa2 = asciiBytes.Length > 0
var csa2 = asciiBytes.Length > 1
? Code128Code.CodesetAllowedForChar(asciiBytes[1])
: Code128Code.CodeSetAllowed.CodeAorB;
var currentCodeSet = this.GetBestStartSet(csa1, csa2);
Expand Down
12 changes: 12 additions & 0 deletions Source/GenCode128Tests/ContentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,5 +372,17 @@ public void FullStringTest()
result = content.Codes;
Assert.AreEqual(10, result.Length, "Wrong number of code values in result");
}

[Test]
public void OneCharStringTest()
{
var content = new Code128Content("0");
var result = content.Codes;
Assert.AreEqual(4, result.Length, "Wrong number of code values in result");
Assert.AreEqual(104, result[0], "Start code wrong");
Assert.AreEqual(16, result[1], "Code value #1 wrong");
Assert.AreEqual(17, result[2], "Checksum wrong");
Assert.AreEqual(106, result[3], "Stop character wrong");
}
}
}