Skip to content

Commit

Permalink
fixed bug found by unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xremix committed Jun 26, 2017
1 parent 4e10db7 commit d052f0d
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 17 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ A GS1 Barcode Library and Parser for Swift Edit
https://github.com/xremix/SwiftGS1Barcode

## Deployment Steps
- Update Version
- Run Unit Tests
- Update Version in `Project Settings` and `Pod Specs`
- Push Code to Git
- Create Release on Git
- `pod lib lint`
Expand All @@ -19,4 +20,4 @@ https://www.activebarcode.de/codes/ean128_ucc128_ai.html
https://www.gs1.at/fileadmin/user_upload/Liste_GS1_Austria_Application_Identifier.pdf

#### CocoaPod
https://www.appcoda.com/cocoapods-making-guide/
https://www.appcoda.com/cocoapods-making-guide/
2 changes: 1 addition & 1 deletion SwiftGS1Barcode.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'SwiftGS1Barcode'
s.version = '0.1.1'
s.version = '0.1.2'
s.summary = 'A GS1 Barcode Library and Parser for Swift'

s.description = <<-DESC
Expand Down
4 changes: 4 additions & 0 deletions SwiftGS1Barcode.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
64754D121F01106D00B22B62 /* GS1BarcodeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64754D111F01106D00B22B62 /* GS1BarcodeTests.swift */; };
64754D141F01107500B22B62 /* StringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64754D131F01107500B22B62 /* StringTests.swift */; };
64754D161F01107B00B22B62 /* DateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64754D151F01107B00B22B62 /* DateTests.swift */; };
64754D181F011B9700B22B62 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 64754D171F011B9700B22B62 /* README.md */; };
64AE611D1F01081800F3B9C0 /* SwiftGS1Barcode.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 64AE61131F01081800F3B9C0 /* SwiftGS1Barcode.framework */; };
64AE61241F01081800F3B9C0 /* SwiftGS1Barcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 64AE61161F01081800F3B9C0 /* SwiftGS1Barcode.h */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -46,6 +47,7 @@
64754D111F01106D00B22B62 /* GS1BarcodeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GS1BarcodeTests.swift; sourceTree = "<group>"; };
64754D131F01107500B22B62 /* StringTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringTests.swift; sourceTree = "<group>"; };
64754D151F01107B00B22B62 /* DateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DateTests.swift; sourceTree = "<group>"; };
64754D171F011B9700B22B62 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
64AE61131F01081800F3B9C0 /* SwiftGS1Barcode.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftGS1Barcode.framework; sourceTree = BUILT_PRODUCTS_DIR; };
64AE61161F01081800F3B9C0 /* SwiftGS1Barcode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftGS1Barcode.h; sourceTree = "<group>"; };
64AE61171F01081800F3B9C0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -75,6 +77,7 @@
64AE61091F01081800F3B9C0 = {
isa = PBXGroup;
children = (
64754D171F011B9700B22B62 /* README.md */,
64754D091F010EFA00B22B62 /* SwiftGS1Barcode.podspec */,
64AE61151F01081800F3B9C0 /* SwiftGS1Barcode */,
64AE61201F01081800F3B9C0 /* SwiftGS1BarcodeTests */,
Expand Down Expand Up @@ -236,6 +239,7 @@
64754D041F010EA000B22B62 /* SimpleBarcode.swift in Sources */,
64754D081F010ECA00B22B62 /* DateExtension.swift in Sources */,
64754CFE1F010A1000B22B62 /* GS1Barcode.swift in Sources */,
64754D181F011B9700B22B62 /* README.md in Sources */,
64754D061F010EBB00B22B62 /* StringExtension.swift in Sources */,
64754D001F010E8400B22B62 /* BarcodeParser.swift in Sources */,
64754D021F010E9100B22B62 /* Barcode.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions SwiftGS1Barcode/GS1Barcode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public class GS1Barcode: NSObject, Barcode {
var serialNumber: String?{ get {return nodes.serialNumberNode.value} }
var amount: Int?{ get {return nodes.amountNode.intValue} }

required override init() {
required override public init() {
super.init()
}
required init(raw: String) {
required public init(raw: String) {
super.init()
self.raw = raw
_ = parse()
Expand Down
2 changes: 1 addition & 1 deletion SwiftGS1Barcode/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.1.1</string>
<string>0.1.2</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
63 changes: 52 additions & 11 deletions SwiftGS1BarcodeTests/GS1BarcodeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,69 @@
import XCTest
@testable import SwiftGS1Barcode

class GS1BarcodeTests: XCTestCase {

class BarcodeTests: XCTestCase {
var barcode: GS1Barcode!
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
// Should parse 01, 30, 17, 10, is a LOT, no Serial
let gs1Barcode = "01101234670420223005\u{1d}172101311010022247"
barcode = GS1Barcode(raw: gs1Barcode)
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
barcode = nil
}

func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
let barcode = GS1Barcode(raw: "01001234670210133001\u{1D}2110066600")
XCTAssert(barcode.validate())
XCTAssertNotNil(barcode.gtin)
XCTAssertEqual(barcode.gtin, "00123467021013")
XCTAssertNil(barcode.lotNumber)

XCTAssertNotNil(barcode.amount)
XCTAssertNotNil(barcode.serialNumber)
XCTAssertEqual(barcode.amount, 1)
XCTAssertEqual(barcode.gtin, "00123467021013")
XCTAssertEqual(barcode.serialNumber, "10066600")
}



func testGTIN() {
XCTAssertNotNil(barcode.gtin)
XCTAssertNotEqual(barcode.gtin, "")
XCTAssertEqual(barcode.gtin, "10123467042022")
}

// func testGETINIndicator(){
// XCTAssertNotNil(barcode.GETINIndicatorDigit)
// XCTAssertEqual(barcode.GETINIndicatorDigit, 1)
// }

func testLot(){
// XCTAssertTrue(barcode.isLot!)
XCTAssertNotNil(barcode.lotNumber)
XCTAssertEqual(barcode.lotNumber, "10022247")
}
func testSerial(){
XCTAssertNil(barcode.serialNumber)
}

func testQuantity(){
XCTAssertNotNil(barcode.amount)
XCTAssertEqual(barcode.amount, 5)
// XCTAssertTrue(barcode.hasQuantityTag!)
}

func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
func testExpirationDate(){
XCTAssertNotNil(barcode.nodes.expirationDateNode.rawValue)
XCTAssertNotNil(barcode.expirationDate)
XCTAssertEqual(barcode.expirationDate, NSDate.from(year: 2021, month: 1, day: 31))
}

// func testValidation(){
// XCTAssertTrue(barcode.validateGS1QuantityRule())
// }
}

0 comments on commit d052f0d

Please sign in to comment.