Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyxo committed May 6, 2015
2 parents 65421ed + 95e690a commit 163c893
Show file tree
Hide file tree
Showing 23 changed files with 640 additions and 1,101 deletions.
49 changes: 49 additions & 0 deletions src/ProtocolBuffers/ProtocolBuffersTests/MessageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
import Foundation
import XCTest


func == (lhs: RegularPoint, rhs: RegularPoint) -> Bool {
return lhs.latitude == rhs.latitude &&
lhs.longitude == rhs.longitude
}

class RegularPoint: Equatable {
var latitude:Float = Float(0)
var longitude:Float = Float(0)
}

class MessageTests: XCTestCase {

override func setUp() {
Expand Down Expand Up @@ -127,4 +138,42 @@ class MessageTests: XCTestCase {
XCTAssertFalse(message.buildPartial().isInitialized(), "")
}


///Issue #61
func testProtoPointWorks() {
var point1 = PBProtoPoint.builder().setLatitude(1.0).setLongitude(1.0).build()
var point2 = PBProtoPoint.builder().setLatitude(2.0).setLongitude(2.0).build()

XCTAssert(point1.latitude == 1.0, "")
XCTAssert(point2.latitude == 2.0, "")

// Succeeds, calls the == function from ProtoPoint.pb.swift as expected
XCTAssert(!(point1 == point2), "")
}

func testProtoPointShouldWork() {
var point1 = PBProtoPoint.builder().setLatitude(1.0).setLongitude(1.0).build()
var point2 = PBProtoPoint.builder().setLatitude(2.0).setLongitude(2.0).build()

XCTAssert(point1.latitude == 1.0, "")
XCTAssert(point2.latitude == 2.0, "")

// Fails, should call the == function from ProtoPoint.pb.swift and take the inverse just like the testRegularPoint() does. But that doesn't happen.
XCTAssert(point1 != point2, "")
}
}

class RegularPointEqualityTest: XCTestCase {
func testRegularPoint() {
var point1 = RegularPoint()
point1.latitude = 1.0
point1.longitude = 1.0

var point2 = RegularPoint()
point2.latitude = 2.0
point2.longitude = 2.0

// works fine, calls the == function and takes the inverse implicitly (put break point to check)
XCTAssert(point1 != point2, "")
}
}
Loading

0 comments on commit 163c893

Please sign in to comment.