How to use Result class

Best Mockingbird code snippet using Result

ResponseSerializationTests.swift

Source:ResponseSerializationTests.swift Github

copy

Full Screen

1// ResponseSerializationTests.swift2//3// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/)4//5// Permission is hereby granted, free of charge, to any person obtaining a copy6// of this software and associated documentation files (the "Software"), to deal7// in the Software without restriction, including without limitation the rights8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell9// copies of the Software, and to permit persons to whom the Software is10// furnished to do so, subject to the following conditions:11//12// The above copyright notice and this permission notice shall be included in13// all copies or substantial portions of the Software.14//15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN21// THE SOFTWARE.22import Alamofire23import Foundation24import XCTest25class ResponseSerializationTestCase: BaseTestCase {26 let error = NSError(domain: Error.Domain, code: -10000, userInfo: nil)27 // MARK: - Data Response Serializer Tests28 func testThatDataResponseSerializerSucceedsWhenDataIsNotNil() {29 // Given30 let serializer = Request.dataResponseSerializer()31 let data = "data".dataUsingEncoding(NSUTF8StringEncoding)!32 // When33 let result = serializer.serializeResponse(nil, nil, data, nil)34 // Then35 XCTAssertTrue(result.isSuccess, "result is success should be true")36 XCTAssertNotNil(result.value, "result value should not be nil")37 XCTAssertNil(result.error, "result error should be nil")38 }39 func testThatDataResponseSerializerFailsWhenDataIsNil() {40 // Given41 let serializer = Request.dataResponseSerializer()42 // When43 let result = serializer.serializeResponse(nil, nil, nil, nil)44 // Then45 XCTAssertTrue(result.isFailure, "result is failure should be true")46 XCTAssertNil(result.value, "result value should be nil")47 XCTAssertNotNil(result.error, "result error should not be nil")48 if let error = result.error {49 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")50 XCTAssertEqual(error.code, Error.Code.DataSerializationFailed.rawValue, "error code should match expected value")51 } else {52 XCTFail("error should not be nil")53 }54 }55 func testThatDataResponseSerializerFailsWhenErrorIsNotNil() {56 // Given57 let serializer = Request.dataResponseSerializer()58 // When59 let result = serializer.serializeResponse(nil, nil, nil, error)60 // Then61 XCTAssertTrue(result.isFailure, "result is failure should be true")62 XCTAssertNil(result.value, "result value should be nil")63 XCTAssertNotNil(result.error, "result error should not be nil")64 if let error = result.error {65 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")66 XCTAssertEqual(error.code, self.error.code, "error code should match expected value")67 } else {68 XCTFail("error should not be nil")69 }70 }71 func testThatDataResponseSerializerFailsWhenDataIsNilWithNon204ResponseStatusCode() {72 // Given73 let serializer = Request.dataResponseSerializer()74 let URL = NSURL(string: "https://httpbin.org/get")!75 let response = NSHTTPURLResponse(URL: URL, statusCode: 200, HTTPVersion: "HTTP/1.1", headerFields: nil)76 // When77 let result = serializer.serializeResponse(nil, response, nil, nil)78 // Then79 XCTAssertTrue(result.isFailure, "result is failure should be true")80 XCTAssertNil(result.value, "result value should be nil")81 XCTAssertNotNil(result.error, "result error should not be nil")82 if let error = result.error {83 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")84 XCTAssertEqual(error.code, Error.Code.DataSerializationFailed.rawValue, "error code should match expected value")85 } else {86 XCTFail("error should not be nil")87 }88 }89 func testThatDataResponseSerializerSucceedsWhenDataIsNilWith204ResponseStatusCode() {90 // Given91 let serializer = Request.dataResponseSerializer()92 let URL = NSURL(string: "https://httpbin.org/get")!93 let response = NSHTTPURLResponse(URL: URL, statusCode: 204, HTTPVersion: "HTTP/1.1", headerFields: nil)94 // When95 let result = serializer.serializeResponse(nil, response, nil, nil)96 // Then97 XCTAssertTrue(result.isSuccess, "result is success should be true")98 XCTAssertNotNil(result.value, "result value should not be nil")99 XCTAssertNil(result.error, "result error should be nil")100 if let data = result.value {101 XCTAssertEqual(data.length, 0, "data length should be zero")102 }103 }104 // MARK: - String Response Serializer Tests105 func testThatStringResponseSerializerFailsWhenDataIsNil() {106 // Given107 let serializer = Request.stringResponseSerializer()108 // When109 let result = serializer.serializeResponse(nil, nil, nil, nil)110 // Then111 XCTAssertTrue(result.isFailure, "result is failure should be true")112 XCTAssertNil(result.value, "result value should be nil")113 XCTAssertNotNil(result.error, "result error should not be nil")114 if let error = result.error {115 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")116 XCTAssertEqual(error.code, Error.Code.StringSerializationFailed.rawValue, "error code should match expected value")117 } else {118 XCTFail("error should not be nil")119 }120 }121 func testThatStringResponseSerializerSucceedsWhenDataIsEmpty() {122 // Given123 let serializer = Request.stringResponseSerializer()124 // When125 let result = serializer.serializeResponse(nil, nil, NSData(), nil)126 // Then127 XCTAssertTrue(result.isSuccess, "result is success should be true")128 XCTAssertNotNil(result.value, "result value should not be nil")129 XCTAssertNil(result.error, "result error should be nil")130 }131 func testThatStringResponseSerializerSucceedsWithUTF8DataAndNoProvidedEncoding() {132 let serializer = Request.stringResponseSerializer()133 let data = "data".dataUsingEncoding(NSUTF8StringEncoding)!134 // When135 let result = serializer.serializeResponse(nil, nil, data, nil)136 // Then137 XCTAssertTrue(result.isSuccess, "result is success should be true")138 XCTAssertNotNil(result.value, "result value should not be nil")139 XCTAssertNil(result.error, "result error should be nil")140 }141 func testThatStringResponseSerializerSucceedsWithUTF8DataAndUTF8ProvidedEncoding() {142 let serializer = Request.stringResponseSerializer(encoding: NSUTF8StringEncoding)143 let data = "data".dataUsingEncoding(NSUTF8StringEncoding)!144 // When145 let result = serializer.serializeResponse(nil, nil, data, nil)146 // Then147 XCTAssertTrue(result.isSuccess, "result is success should be true")148 XCTAssertNotNil(result.value, "result value should not be nil")149 XCTAssertNil(result.error, "result error should be nil")150 }151 func testThatStringResponseSerializerSucceedsWithUTF8DataUsingResponseTextEncodingName() {152 let serializer = Request.stringResponseSerializer()153 let data = "data".dataUsingEncoding(NSUTF8StringEncoding)!154 let response = NSHTTPURLResponse(155 URL: NSURL(string: "https://httpbin.org/get")!,156 statusCode: 200,157 HTTPVersion: "HTTP/1.1",158 headerFields: ["Content-Type": "image/jpeg; charset=utf-8"]159 )160 // When161 let result = serializer.serializeResponse(nil, response, data, nil)162 // Then163 XCTAssertTrue(result.isSuccess, "result is success should be true")164 XCTAssertNotNil(result.value, "result value should not be nil")165 XCTAssertNil(result.error, "result error should be nil")166 }167 func testThatStringResponseSerializerFailsWithUTF32DataAndUTF8ProvidedEncoding() {168 // Given169 let serializer = Request.stringResponseSerializer(encoding: NSUTF8StringEncoding)170 let data = "random data".dataUsingEncoding(NSUTF32StringEncoding)!171 // When172 let result = serializer.serializeResponse(nil, nil, data, nil)173 // Then174 XCTAssertTrue(result.isFailure, "result is failure should be true")175 XCTAssertNil(result.value, "result value should be nil")176 XCTAssertNotNil(result.error, "result error should not be nil")177 if let error = result.error {178 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")179 XCTAssertEqual(error.code, Error.Code.StringSerializationFailed.rawValue, "error code should match expected value")180 } else {181 XCTFail("error should not be nil")182 }183 }184 func testThatStringResponseSerializerFailsWithUTF32DataAndUTF8ResponseEncoding() {185 // Given186 let serializer = Request.stringResponseSerializer()187 let data = "random data".dataUsingEncoding(NSUTF32StringEncoding)!188 let response = NSHTTPURLResponse(189 URL: NSURL(string: "https://httpbin.org/get")!,190 statusCode: 200,191 HTTPVersion: "HTTP/1.1",192 headerFields: ["Content-Type": "image/jpeg; charset=utf-8"]193 )194 // When195 let result = serializer.serializeResponse(nil, response, data, nil)196 // Then197 XCTAssertTrue(result.isFailure, "result is failure should be true")198 XCTAssertNil(result.value, "result value should be nil")199 XCTAssertNotNil(result.error, "result error should not be nil")200 if let error = result.error {201 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")202 XCTAssertEqual(error.code, Error.Code.StringSerializationFailed.rawValue, "error code should match expected value")203 } else {204 XCTFail("error should not be nil")205 }206 }207 func testThatStringResponseSerializerFailsWhenErrorIsNotNil() {208 // Given209 let serializer = Request.stringResponseSerializer()210 // When211 let result = serializer.serializeResponse(nil, nil, nil, error)212 // Then213 XCTAssertTrue(result.isFailure, "result is failure should be true")214 XCTAssertNil(result.value, "result value should be nil")215 XCTAssertNotNil(result.error, "result error should not be nil")216 if let error = result.error {217 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")218 XCTAssertEqual(error.code, self.error.code, "error code should match expected value")219 } else {220 XCTFail("error should not be nil")221 }222 }223 func testThatStringResponseSerializerFailsWhenDataIsNilWithNon204ResponseStatusCode() {224 // Given225 let serializer = Request.stringResponseSerializer()226 let URL = NSURL(string: "https://httpbin.org/get")!227 let response = NSHTTPURLResponse(URL: URL, statusCode: 200, HTTPVersion: "HTTP/1.1", headerFields: nil)228 // When229 let result = serializer.serializeResponse(nil, response, nil, nil)230 // Then231 XCTAssertTrue(result.isFailure, "result is failure should be true")232 XCTAssertNil(result.value, "result value should be nil")233 XCTAssertNotNil(result.error, "result error should not be nil")234 if let error = result.error {235 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")236 XCTAssertEqual(error.code, Error.Code.StringSerializationFailed.rawValue, "error code should match expected value")237 } else {238 XCTFail("error should not be nil")239 }240 }241 func testThatStringResponseSerializerSucceedsWhenDataIsNilWith204ResponseStatusCode() {242 // Given243 let serializer = Request.stringResponseSerializer()244 let URL = NSURL(string: "https://httpbin.org/get")!245 let response = NSHTTPURLResponse(URL: URL, statusCode: 204, HTTPVersion: "HTTP/1.1", headerFields: nil)246 // When247 let result = serializer.serializeResponse(nil, response, nil, nil)248 // Then249 XCTAssertTrue(result.isSuccess, "result is success should be true")250 XCTAssertNotNil(result.value, "result value should not be nil")251 XCTAssertNil(result.error, "result error should be nil")252 if let string = result.value {253 XCTAssertEqual(string, "", "string should be equal to empty string")254 }255 }256 // MARK: - JSON Response Serializer Tests257 func testThatJSONResponseSerializerFailsWhenDataIsNil() {258 // Given259 let serializer = Request.JSONResponseSerializer()260 // When261 let result = serializer.serializeResponse(nil, nil, nil, nil)262 // Then263 XCTAssertTrue(result.isFailure, "result is failure should be true")264 XCTAssertNil(result.value, "result value should be nil")265 XCTAssertNotNil(result.error, "result error should not be nil")266 if let error = result.error {267 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")268 XCTAssertEqual(error.code, Error.Code.JSONSerializationFailed.rawValue, "error code should match expected value")269 } else {270 XCTFail("error should not be nil")271 }272 }273 func testThatJSONResponseSerializerFailsWhenDataIsEmpty() {274 // Given275 let serializer = Request.JSONResponseSerializer()276 // When277 let result = serializer.serializeResponse(nil, nil, NSData(), nil)278 // Then279 XCTAssertTrue(result.isFailure, "result is failure should be true")280 XCTAssertNil(result.value, "result value should be nil")281 XCTAssertNotNil(result.error, "result error should not be nil")282 if let error = result.error {283 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")284 XCTAssertEqual(error.code, Error.Code.JSONSerializationFailed.rawValue, "error code should match expected value")285 } else {286 XCTFail("error should not be nil")287 }288 }289 func testThatJSONResponseSerializerSucceedsWhenDataIsValidJSON() {290 // Given291 let serializer = Request.JSONResponseSerializer()292 let data = "{\"json\": true}".dataUsingEncoding(NSUTF8StringEncoding)!293 // When294 let result = serializer.serializeResponse(nil, nil, data, nil)295 // Then296 XCTAssertTrue(result.isSuccess, "result is success should be true")297 XCTAssertNotNil(result.value, "result value should not be nil")298 XCTAssertNil(result.error, "result error should be nil")299 }300 func testThatJSONResponseSerializerFailsWhenDataIsInvalidJSON() {301 // Given302 let serializer = Request.JSONResponseSerializer()303 let data = "definitely not valid json".dataUsingEncoding(NSUTF8StringEncoding)!304 // When305 let result = serializer.serializeResponse(nil, nil, data, nil)306 // Then307 XCTAssertTrue(result.isFailure, "result is failure should be true")308 XCTAssertNil(result.value, "result value should be nil")309 XCTAssertNotNil(result.error, "result error should not be nil")310 if let error = result.error {311 XCTAssertEqual(error.domain, NSCocoaErrorDomain, "error domain should match expected value")312 XCTAssertEqual(error.code, 3840, "error code should match expected value")313 } else {314 XCTFail("error should not be nil")315 }316 }317 func testThatJSONResponseSerializerFailsWhenErrorIsNotNil() {318 // Given319 let serializer = Request.JSONResponseSerializer()320 // When321 let result = serializer.serializeResponse(nil, nil, nil, error)322 // Then323 XCTAssertTrue(result.isFailure, "result is failure should be true")324 XCTAssertNil(result.value, "result value should be nil")325 XCTAssertNotNil(result.error, "result error should not be nil")326 if let error = result.error {327 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")328 XCTAssertEqual(error.code, self.error.code, "error code should match expected value")329 } else {330 XCTFail("error should not be nil")331 }332 }333 func testThatJSONResponseSerializerFailsWhenDataIsNilWithNon204ResponseStatusCode() {334 // Given335 let serializer = Request.JSONResponseSerializer()336 let URL = NSURL(string: "https://httpbin.org/get")!337 let response = NSHTTPURLResponse(URL: URL, statusCode: 200, HTTPVersion: "HTTP/1.1", headerFields: nil)338 // When339 let result = serializer.serializeResponse(nil, response, nil, nil)340 // Then341 XCTAssertTrue(result.isFailure, "result is failure should be true")342 XCTAssertNil(result.value, "result value should be nil")343 XCTAssertNotNil(result.error, "result error should not be nil")344 if let error = result.error {345 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")346 XCTAssertEqual(error.code, Error.Code.JSONSerializationFailed.rawValue, "error code should match expected value")347 } else {348 XCTFail("error should not be nil")349 }350 }351 func testThatJSONResponseSerializerSucceedsWhenDataIsNilWith204ResponseStatusCode() {352 // Given353 let serializer = Request.JSONResponseSerializer()354 let URL = NSURL(string: "https://httpbin.org/get")!355 let response = NSHTTPURLResponse(URL: URL, statusCode: 204, HTTPVersion: "HTTP/1.1", headerFields: nil)356 // When357 let result = serializer.serializeResponse(nil, response, nil, nil)358 // Then359 XCTAssertTrue(result.isSuccess, "result is success should be true")360 XCTAssertNotNil(result.value, "result value should not be nil")361 XCTAssertNil(result.error, "result error should be nil")362 if let json = result.value as? NSNull {363 XCTAssertEqual(json, NSNull(), "json should be equal to NSNull")364 }365 }366 // MARK: - Property List Response Serializer Tests367 func testThatPropertyListResponseSerializerFailsWhenDataIsNil() {368 // Given369 let serializer = Request.propertyListResponseSerializer()370 // When371 let result = serializer.serializeResponse(nil, nil, nil, nil)372 // Then373 XCTAssertTrue(result.isFailure, "result is failure should be true")374 XCTAssertNil(result.value, "result value should be nil")375 XCTAssertNotNil(result.error, "result error should not be nil")376 if let error = result.error {377 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")378 XCTAssertEqual(error.code, Error.Code.PropertyListSerializationFailed.rawValue, "error code should match expected value")379 } else {380 XCTFail("error should not be nil")381 }382 }383 func testThatPropertyListResponseSerializerFailsWhenDataIsEmpty() {384 // Given385 let serializer = Request.propertyListResponseSerializer()386 // When387 let result = serializer.serializeResponse(nil, nil, NSData(), nil)388 // Then389 XCTAssertTrue(result.isFailure, "result is failure should be true")390 XCTAssertNil(result.value, "result value should be nil")391 XCTAssertNotNil(result.error, "result error should not be nil")392 if let error = result.error {393 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")394 XCTAssertEqual(error.code, Error.Code.PropertyListSerializationFailed.rawValue, "error code should match expected value")395 } else {396 XCTFail("error should not be nil")397 }398 }399 func testThatPropertyListResponseSerializerSucceedsWhenDataIsValidPropertyListData() {400 // Given401 let serializer = Request.propertyListResponseSerializer()402 let data = NSKeyedArchiver.archivedDataWithRootObject(["foo": "bar"])403 // When404 let result = serializer.serializeResponse(nil, nil, data, nil)405 // Then406 XCTAssertTrue(result.isSuccess, "result is success should be true")407 XCTAssertNotNil(result.value, "result value should not be nil")408 XCTAssertNil(result.error, "result error should be nil")409 }410 func testThatPropertyListResponseSerializerFailsWhenDataIsInvalidPropertyListData() {411 // Given412 let serializer = Request.propertyListResponseSerializer()413 let data = "definitely not valid plist data".dataUsingEncoding(NSUTF8StringEncoding)!414 // When415 let result = serializer.serializeResponse(nil, nil, data, nil)416 // Then417 XCTAssertTrue(result.isFailure, "result is failure should be true")418 XCTAssertNil(result.value, "result value should be nil")419 XCTAssertNotNil(result.error, "result error should not be nil")420 if let error = result.error {421 XCTAssertEqual(error.domain, NSCocoaErrorDomain, "error domain should match expected value")422 XCTAssertEqual(error.code, 3840, "error code should match expected value")423 } else {424 XCTFail("error should not be nil")425 }426 }427 func testThatPropertyListResponseSerializerFailsWhenErrorIsNotNil() {428 // Given429 let serializer = Request.propertyListResponseSerializer()430 // When431 let result = serializer.serializeResponse(nil, nil, nil, error)432 // Then433 XCTAssertTrue(result.isFailure, "result is failure should be true")434 XCTAssertNil(result.value, "result value should be nil")435 XCTAssertNotNil(result.error, "result error should not be nil")436 if let error = result.error {437 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")438 XCTAssertEqual(error.code, self.error.code, "error code should match expected value")439 } else {440 XCTFail("error should not be nil")441 }442 }443 func testThatPropertyListResponseSerializerFailsWhenDataIsNilWithNon204ResponseStatusCode() {444 // Given445 let serializer = Request.propertyListResponseSerializer()446 let URL = NSURL(string: "https://httpbin.org/get")!447 let response = NSHTTPURLResponse(URL: URL, statusCode: 200, HTTPVersion: "HTTP/1.1", headerFields: nil)448 // When449 let result = serializer.serializeResponse(nil, response, nil, nil)450 // Then451 XCTAssertTrue(result.isFailure, "result is failure should be true")452 XCTAssertNil(result.value, "result value should be nil")453 XCTAssertNotNil(result.error, "result error should not be nil")454 if let error = result.error {455 XCTAssertEqual(error.domain, Error.Domain, "error domain should match expected value")456 XCTAssertEqual(error.code, Error.Code.PropertyListSerializationFailed.rawValue, "error code should match expected value")457 } else {458 XCTFail("error should not be nil")459 }460 }461 func testThatPropertyListResponseSerializerSucceedsWhenDataIsNilWith204ResponseStatusCode() {462 // Given463 let serializer = Request.propertyListResponseSerializer()464 let URL = NSURL(string: "https://httpbin.org/get")!465 let response = NSHTTPURLResponse(URL: URL, statusCode: 204, HTTPVersion: "HTTP/1.1", headerFields: nil)466 // When467 let result = serializer.serializeResponse(nil, response, nil, nil)468 // Then469 XCTAssertTrue(result.isSuccess, "result is success should be true")470 XCTAssertNotNil(result.value, "result value should not be nil")471 XCTAssertNil(result.error, "result error should be nil")472 if let plist = result.value as? NSNull {473 XCTAssertEqual(plist, NSNull(), "plist should be equal to NSNull")474 }475 }476}...

Full Screen

Full Screen

consensus.go

Source:consensus.go Github

copy

Full Screen

1/* ----------------------------------------------------------------------------2 * This file was automatically generated by SWIG (http://www.swig.org).3 * Version 3.0.84 *5 * This file is not intended to be easily readable and contains a number of6 * coding conventions designed to improve portability and efficiency. Do not make7 * changes to this file unless you know what you are doing--modify the SWIG8 * interface file instead.9 * ----------------------------------------------------------------------------- */10// source: consensus.swg11package consensus12/*13#define intgo swig_intgo14typedef void *swig_voidp;15#include <stdint.h>16typedef int intgo;17typedef unsigned int uintgo;18typedef struct { char *p; intgo n; } _gostring_;19typedef struct { void* array; intgo len; intgo cap; } _goslice_;20typedef long long swig_type_1;21typedef long long swig_type_2;22extern void _wrap_Swig_free_consensus_0731991c73947514(uintptr_t arg1);23extern swig_intgo _wrap_verify_result_eval_false_consensus_0731991c73947514(void);24extern swig_intgo _wrap_verify_result_eval_true_consensus_0731991c73947514(void);25extern swig_intgo _wrap_verify_result_script_size_consensus_0731991c73947514(void);26extern swig_intgo _wrap_verify_result_push_size_consensus_0731991c73947514(void);27extern swig_intgo _wrap_verify_result_op_count_consensus_0731991c73947514(void);28extern swig_intgo _wrap_verify_result_stack_size_consensus_0731991c73947514(void);29extern swig_intgo _wrap_verify_result_sig_count_consensus_0731991c73947514(void);30extern swig_intgo _wrap_verify_result_pubkey_count_consensus_0731991c73947514(void);31extern swig_intgo _wrap_verify_result_verify_consensus_0731991c73947514(void);32extern swig_intgo _wrap_verify_result_equalverify_consensus_0731991c73947514(void);33extern swig_intgo _wrap_verify_result_checkmultisigverify_consensus_0731991c73947514(void);34extern swig_intgo _wrap_verify_result_checksigverify_consensus_0731991c73947514(void);35extern swig_intgo _wrap_verify_result_numequalverify_consensus_0731991c73947514(void);36extern swig_intgo _wrap_verify_result_bad_opcode_consensus_0731991c73947514(void);37extern swig_intgo _wrap_verify_result_disabled_opcode_consensus_0731991c73947514(void);38extern swig_intgo _wrap_verify_result_invalid_stack_operation_consensus_0731991c73947514(void);39extern swig_intgo _wrap_verify_result_invalid_altstack_operation_consensus_0731991c73947514(void);40extern swig_intgo _wrap_verify_result_unbalanced_conditional_consensus_0731991c73947514(void);41extern swig_intgo _wrap_verify_result_sig_hashtype_consensus_0731991c73947514(void);42extern swig_intgo _wrap_verify_result_sig_der_consensus_0731991c73947514(void);43extern swig_intgo _wrap_verify_result_minimaldata_consensus_0731991c73947514(void);44extern swig_intgo _wrap_verify_result_sig_pushonly_consensus_0731991c73947514(void);45extern swig_intgo _wrap_verify_result_sig_high_s_consensus_0731991c73947514(void);46extern swig_intgo _wrap_verify_result_sig_nulldummy_consensus_0731991c73947514(void);47extern swig_intgo _wrap_verify_result_pubkeytype_consensus_0731991c73947514(void);48extern swig_intgo _wrap_verify_result_cleanstack_consensus_0731991c73947514(void);49extern swig_intgo _wrap_verify_result_discourage_upgradable_nops_consensus_0731991c73947514(void);50extern swig_intgo _wrap_verify_result_op_return_consensus_0731991c73947514(void);51extern swig_intgo _wrap_verify_result_unknown_error_consensus_0731991c73947514(void);52extern swig_intgo _wrap_verify_result_tx_invalid_consensus_0731991c73947514(void);53extern swig_intgo _wrap_verify_result_tx_size_invalid_consensus_0731991c73947514(void);54extern swig_intgo _wrap_verify_result_tx_input_invalid_consensus_0731991c73947514(void);55extern swig_intgo _wrap_verify_result_negative_locktime_consensus_0731991c73947514(void);56extern swig_intgo _wrap_verify_result_unsatisfied_locktime_consensus_0731991c73947514(void);57extern swig_intgo _wrap_verify_flags_none_consensus_0731991c73947514(void);58extern swig_intgo _wrap_verify_flags_p2sh_consensus_0731991c73947514(void);59extern swig_intgo _wrap_verify_flags_strictenc_consensus_0731991c73947514(void);60extern swig_intgo _wrap_verify_flags_dersig_consensus_0731991c73947514(void);61extern swig_intgo _wrap_verify_flags_low_s_consensus_0731991c73947514(void);62extern swig_intgo _wrap_verify_flags_nulldummy_consensus_0731991c73947514(void);63extern swig_intgo _wrap_verify_flags_sigpushonly_consensus_0731991c73947514(void);64extern swig_intgo _wrap_verify_flags_minimaldata_consensus_0731991c73947514(void);65extern swig_intgo _wrap_verify_flags_discourage_upgradable_nops_consensus_0731991c73947514(void);66extern swig_intgo _wrap_verify_flags_cleanstack_consensus_0731991c73947514(void);67extern swig_intgo _wrap_verify_flags_checklocktimeverify_consensus_0731991c73947514(void);68extern swig_intgo _wrap_verify_script_consensus_0731991c73947514(swig_voidp arg1, swig_type_1 arg2, swig_voidp arg3, swig_type_2 arg4, swig_intgo arg5, swig_intgo arg6);69#undef intgo70*/71import "C"72import "unsafe"73import _ "runtime/cgo"74import "sync"75type _ unsafe.Pointer76var Swig_escape_always_false bool77var Swig_escape_val interface{}78type _swig_fnptr *byte79type _swig_memberptr *byte80type _ sync.Mutex81func Swig_free(arg1 uintptr) {82 _swig_i_0 := arg183 C._wrap_Swig_free_consensus_0731991c73947514(C.uintptr_t(_swig_i_0))84}85const LIBBITCOIN_CONSENSUS_VERSION string = "2.0.0"86const LIBBITCOIN_CONSENSUS_MAJOR_VERSION int = 287const LIBBITCOIN_CONSENSUS_MINOR_VERSION int = 088const LIBBITCOIN_CONSENSUS_PATCH_VERSION int = 089type LibbitcoinConsensusVerify_result_type int90func _swig_getverify_result_eval_false() (_swig_ret LibbitcoinConsensusVerify_result_type) {91 var swig_r LibbitcoinConsensusVerify_result_type92 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_eval_false_consensus_0731991c73947514())93 return swig_r94}95var Verify_result_eval_false LibbitcoinConsensusVerify_result_type = _swig_getverify_result_eval_false()96func _swig_getverify_result_eval_true() (_swig_ret LibbitcoinConsensusVerify_result_type) {97 var swig_r LibbitcoinConsensusVerify_result_type98 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_eval_true_consensus_0731991c73947514())99 return swig_r100}101var Verify_result_eval_true LibbitcoinConsensusVerify_result_type = _swig_getverify_result_eval_true()102func _swig_getverify_result_script_size() (_swig_ret LibbitcoinConsensusVerify_result_type) {103 var swig_r LibbitcoinConsensusVerify_result_type104 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_script_size_consensus_0731991c73947514())105 return swig_r106}107var Verify_result_script_size LibbitcoinConsensusVerify_result_type = _swig_getverify_result_script_size()108func _swig_getverify_result_push_size() (_swig_ret LibbitcoinConsensusVerify_result_type) {109 var swig_r LibbitcoinConsensusVerify_result_type110 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_push_size_consensus_0731991c73947514())111 return swig_r112}113var Verify_result_push_size LibbitcoinConsensusVerify_result_type = _swig_getverify_result_push_size()114func _swig_getverify_result_op_count() (_swig_ret LibbitcoinConsensusVerify_result_type) {115 var swig_r LibbitcoinConsensusVerify_result_type116 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_op_count_consensus_0731991c73947514())117 return swig_r118}119var Verify_result_op_count LibbitcoinConsensusVerify_result_type = _swig_getverify_result_op_count()120func _swig_getverify_result_stack_size() (_swig_ret LibbitcoinConsensusVerify_result_type) {121 var swig_r LibbitcoinConsensusVerify_result_type122 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_stack_size_consensus_0731991c73947514())123 return swig_r124}125var Verify_result_stack_size LibbitcoinConsensusVerify_result_type = _swig_getverify_result_stack_size()126func _swig_getverify_result_sig_count() (_swig_ret LibbitcoinConsensusVerify_result_type) {127 var swig_r LibbitcoinConsensusVerify_result_type128 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_sig_count_consensus_0731991c73947514())129 return swig_r130}131var Verify_result_sig_count LibbitcoinConsensusVerify_result_type = _swig_getverify_result_sig_count()132func _swig_getverify_result_pubkey_count() (_swig_ret LibbitcoinConsensusVerify_result_type) {133 var swig_r LibbitcoinConsensusVerify_result_type134 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_pubkey_count_consensus_0731991c73947514())135 return swig_r136}137var Verify_result_pubkey_count LibbitcoinConsensusVerify_result_type = _swig_getverify_result_pubkey_count()138func _swig_getverify_result_verify() (_swig_ret LibbitcoinConsensusVerify_result_type) {139 var swig_r LibbitcoinConsensusVerify_result_type140 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_verify_consensus_0731991c73947514())141 return swig_r142}143var Verify_result_verify LibbitcoinConsensusVerify_result_type = _swig_getverify_result_verify()144func _swig_getverify_result_equalverify() (_swig_ret LibbitcoinConsensusVerify_result_type) {145 var swig_r LibbitcoinConsensusVerify_result_type146 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_equalverify_consensus_0731991c73947514())147 return swig_r148}149var Verify_result_equalverify LibbitcoinConsensusVerify_result_type = _swig_getverify_result_equalverify()150func _swig_getverify_result_checkmultisigverify() (_swig_ret LibbitcoinConsensusVerify_result_type) {151 var swig_r LibbitcoinConsensusVerify_result_type152 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_checkmultisigverify_consensus_0731991c73947514())153 return swig_r154}155var Verify_result_checkmultisigverify LibbitcoinConsensusVerify_result_type = _swig_getverify_result_checkmultisigverify()156func _swig_getverify_result_checksigverify() (_swig_ret LibbitcoinConsensusVerify_result_type) {157 var swig_r LibbitcoinConsensusVerify_result_type158 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_checksigverify_consensus_0731991c73947514())159 return swig_r160}161var Verify_result_checksigverify LibbitcoinConsensusVerify_result_type = _swig_getverify_result_checksigverify()162func _swig_getverify_result_numequalverify() (_swig_ret LibbitcoinConsensusVerify_result_type) {163 var swig_r LibbitcoinConsensusVerify_result_type164 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_numequalverify_consensus_0731991c73947514())165 return swig_r166}167var Verify_result_numequalverify LibbitcoinConsensusVerify_result_type = _swig_getverify_result_numequalverify()168func _swig_getverify_result_bad_opcode() (_swig_ret LibbitcoinConsensusVerify_result_type) {169 var swig_r LibbitcoinConsensusVerify_result_type170 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_bad_opcode_consensus_0731991c73947514())171 return swig_r172}173var Verify_result_bad_opcode LibbitcoinConsensusVerify_result_type = _swig_getverify_result_bad_opcode()174func _swig_getverify_result_disabled_opcode() (_swig_ret LibbitcoinConsensusVerify_result_type) {175 var swig_r LibbitcoinConsensusVerify_result_type176 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_disabled_opcode_consensus_0731991c73947514())177 return swig_r178}179var Verify_result_disabled_opcode LibbitcoinConsensusVerify_result_type = _swig_getverify_result_disabled_opcode()180func _swig_getverify_result_invalid_stack_operation() (_swig_ret LibbitcoinConsensusVerify_result_type) {181 var swig_r LibbitcoinConsensusVerify_result_type182 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_invalid_stack_operation_consensus_0731991c73947514())183 return swig_r184}185var Verify_result_invalid_stack_operation LibbitcoinConsensusVerify_result_type = _swig_getverify_result_invalid_stack_operation()186func _swig_getverify_result_invalid_altstack_operation() (_swig_ret LibbitcoinConsensusVerify_result_type) {187 var swig_r LibbitcoinConsensusVerify_result_type188 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_invalid_altstack_operation_consensus_0731991c73947514())189 return swig_r190}191var Verify_result_invalid_altstack_operation LibbitcoinConsensusVerify_result_type = _swig_getverify_result_invalid_altstack_operation()192func _swig_getverify_result_unbalanced_conditional() (_swig_ret LibbitcoinConsensusVerify_result_type) {193 var swig_r LibbitcoinConsensusVerify_result_type194 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_unbalanced_conditional_consensus_0731991c73947514())195 return swig_r196}197var Verify_result_unbalanced_conditional LibbitcoinConsensusVerify_result_type = _swig_getverify_result_unbalanced_conditional()198func _swig_getverify_result_sig_hashtype() (_swig_ret LibbitcoinConsensusVerify_result_type) {199 var swig_r LibbitcoinConsensusVerify_result_type200 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_sig_hashtype_consensus_0731991c73947514())201 return swig_r202}203var Verify_result_sig_hashtype LibbitcoinConsensusVerify_result_type = _swig_getverify_result_sig_hashtype()204func _swig_getverify_result_sig_der() (_swig_ret LibbitcoinConsensusVerify_result_type) {205 var swig_r LibbitcoinConsensusVerify_result_type206 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_sig_der_consensus_0731991c73947514())207 return swig_r208}209var Verify_result_sig_der LibbitcoinConsensusVerify_result_type = _swig_getverify_result_sig_der()210func _swig_getverify_result_minimaldata() (_swig_ret LibbitcoinConsensusVerify_result_type) {211 var swig_r LibbitcoinConsensusVerify_result_type212 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_minimaldata_consensus_0731991c73947514())213 return swig_r214}215var Verify_result_minimaldata LibbitcoinConsensusVerify_result_type = _swig_getverify_result_minimaldata()216func _swig_getverify_result_sig_pushonly() (_swig_ret LibbitcoinConsensusVerify_result_type) {217 var swig_r LibbitcoinConsensusVerify_result_type218 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_sig_pushonly_consensus_0731991c73947514())219 return swig_r220}221var Verify_result_sig_pushonly LibbitcoinConsensusVerify_result_type = _swig_getverify_result_sig_pushonly()222func _swig_getverify_result_sig_high_s() (_swig_ret LibbitcoinConsensusVerify_result_type) {223 var swig_r LibbitcoinConsensusVerify_result_type224 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_sig_high_s_consensus_0731991c73947514())225 return swig_r226}227var Verify_result_sig_high_s LibbitcoinConsensusVerify_result_type = _swig_getverify_result_sig_high_s()228func _swig_getverify_result_sig_nulldummy() (_swig_ret LibbitcoinConsensusVerify_result_type) {229 var swig_r LibbitcoinConsensusVerify_result_type230 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_sig_nulldummy_consensus_0731991c73947514())231 return swig_r232}233var Verify_result_sig_nulldummy LibbitcoinConsensusVerify_result_type = _swig_getverify_result_sig_nulldummy()234func _swig_getverify_result_pubkeytype() (_swig_ret LibbitcoinConsensusVerify_result_type) {235 var swig_r LibbitcoinConsensusVerify_result_type236 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_pubkeytype_consensus_0731991c73947514())237 return swig_r238}239var Verify_result_pubkeytype LibbitcoinConsensusVerify_result_type = _swig_getverify_result_pubkeytype()240func _swig_getverify_result_cleanstack() (_swig_ret LibbitcoinConsensusVerify_result_type) {241 var swig_r LibbitcoinConsensusVerify_result_type242 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_cleanstack_consensus_0731991c73947514())243 return swig_r244}245var Verify_result_cleanstack LibbitcoinConsensusVerify_result_type = _swig_getverify_result_cleanstack()246func _swig_getverify_result_discourage_upgradable_nops() (_swig_ret LibbitcoinConsensusVerify_result_type) {247 var swig_r LibbitcoinConsensusVerify_result_type248 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_discourage_upgradable_nops_consensus_0731991c73947514())249 return swig_r250}251var Verify_result_discourage_upgradable_nops LibbitcoinConsensusVerify_result_type = _swig_getverify_result_discourage_upgradable_nops()252func _swig_getverify_result_op_return() (_swig_ret LibbitcoinConsensusVerify_result_type) {253 var swig_r LibbitcoinConsensusVerify_result_type254 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_op_return_consensus_0731991c73947514())255 return swig_r256}257var Verify_result_op_return LibbitcoinConsensusVerify_result_type = _swig_getverify_result_op_return()258func _swig_getverify_result_unknown_error() (_swig_ret LibbitcoinConsensusVerify_result_type) {259 var swig_r LibbitcoinConsensusVerify_result_type260 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_unknown_error_consensus_0731991c73947514())261 return swig_r262}263var Verify_result_unknown_error LibbitcoinConsensusVerify_result_type = _swig_getverify_result_unknown_error()264func _swig_getverify_result_tx_invalid() (_swig_ret LibbitcoinConsensusVerify_result_type) {265 var swig_r LibbitcoinConsensusVerify_result_type266 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_tx_invalid_consensus_0731991c73947514())267 return swig_r268}269var Verify_result_tx_invalid LibbitcoinConsensusVerify_result_type = _swig_getverify_result_tx_invalid()270func _swig_getverify_result_tx_size_invalid() (_swig_ret LibbitcoinConsensusVerify_result_type) {271 var swig_r LibbitcoinConsensusVerify_result_type272 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_tx_size_invalid_consensus_0731991c73947514())273 return swig_r274}275var Verify_result_tx_size_invalid LibbitcoinConsensusVerify_result_type = _swig_getverify_result_tx_size_invalid()276func _swig_getverify_result_tx_input_invalid() (_swig_ret LibbitcoinConsensusVerify_result_type) {277 var swig_r LibbitcoinConsensusVerify_result_type278 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_tx_input_invalid_consensus_0731991c73947514())279 return swig_r280}281var Verify_result_tx_input_invalid LibbitcoinConsensusVerify_result_type = _swig_getverify_result_tx_input_invalid()282func _swig_getverify_result_negative_locktime() (_swig_ret LibbitcoinConsensusVerify_result_type) {283 var swig_r LibbitcoinConsensusVerify_result_type284 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_negative_locktime_consensus_0731991c73947514())285 return swig_r286}287var Verify_result_negative_locktime LibbitcoinConsensusVerify_result_type = _swig_getverify_result_negative_locktime()288func _swig_getverify_result_unsatisfied_locktime() (_swig_ret LibbitcoinConsensusVerify_result_type) {289 var swig_r LibbitcoinConsensusVerify_result_type290 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_result_unsatisfied_locktime_consensus_0731991c73947514())291 return swig_r292}293var Verify_result_unsatisfied_locktime LibbitcoinConsensusVerify_result_type = _swig_getverify_result_unsatisfied_locktime()294type LibbitcoinConsensusVerify_flags_type int295func _swig_getverify_flags_none() (_swig_ret LibbitcoinConsensusVerify_flags_type) {296 var swig_r LibbitcoinConsensusVerify_flags_type297 swig_r = (LibbitcoinConsensusVerify_flags_type)(C._wrap_verify_flags_none_consensus_0731991c73947514())298 return swig_r299}300var Verify_flags_none LibbitcoinConsensusVerify_flags_type = _swig_getverify_flags_none()301func _swig_getverify_flags_p2sh() (_swig_ret LibbitcoinConsensusVerify_flags_type) {302 var swig_r LibbitcoinConsensusVerify_flags_type303 swig_r = (LibbitcoinConsensusVerify_flags_type)(C._wrap_verify_flags_p2sh_consensus_0731991c73947514())304 return swig_r305}306var Verify_flags_p2sh LibbitcoinConsensusVerify_flags_type = _swig_getverify_flags_p2sh()307func _swig_getverify_flags_strictenc() (_swig_ret LibbitcoinConsensusVerify_flags_type) {308 var swig_r LibbitcoinConsensusVerify_flags_type309 swig_r = (LibbitcoinConsensusVerify_flags_type)(C._wrap_verify_flags_strictenc_consensus_0731991c73947514())310 return swig_r311}312var Verify_flags_strictenc LibbitcoinConsensusVerify_flags_type = _swig_getverify_flags_strictenc()313func _swig_getverify_flags_dersig() (_swig_ret LibbitcoinConsensusVerify_flags_type) {314 var swig_r LibbitcoinConsensusVerify_flags_type315 swig_r = (LibbitcoinConsensusVerify_flags_type)(C._wrap_verify_flags_dersig_consensus_0731991c73947514())316 return swig_r317}318var Verify_flags_dersig LibbitcoinConsensusVerify_flags_type = _swig_getverify_flags_dersig()319func _swig_getverify_flags_low_s() (_swig_ret LibbitcoinConsensusVerify_flags_type) {320 var swig_r LibbitcoinConsensusVerify_flags_type321 swig_r = (LibbitcoinConsensusVerify_flags_type)(C._wrap_verify_flags_low_s_consensus_0731991c73947514())322 return swig_r323}324var Verify_flags_low_s LibbitcoinConsensusVerify_flags_type = _swig_getverify_flags_low_s()325func _swig_getverify_flags_nulldummy() (_swig_ret LibbitcoinConsensusVerify_flags_type) {326 var swig_r LibbitcoinConsensusVerify_flags_type327 swig_r = (LibbitcoinConsensusVerify_flags_type)(C._wrap_verify_flags_nulldummy_consensus_0731991c73947514())328 return swig_r329}330var Verify_flags_nulldummy LibbitcoinConsensusVerify_flags_type = _swig_getverify_flags_nulldummy()331func _swig_getverify_flags_sigpushonly() (_swig_ret LibbitcoinConsensusVerify_flags_type) {332 var swig_r LibbitcoinConsensusVerify_flags_type333 swig_r = (LibbitcoinConsensusVerify_flags_type)(C._wrap_verify_flags_sigpushonly_consensus_0731991c73947514())334 return swig_r335}336var Verify_flags_sigpushonly LibbitcoinConsensusVerify_flags_type = _swig_getverify_flags_sigpushonly()337func _swig_getverify_flags_minimaldata() (_swig_ret LibbitcoinConsensusVerify_flags_type) {338 var swig_r LibbitcoinConsensusVerify_flags_type339 swig_r = (LibbitcoinConsensusVerify_flags_type)(C._wrap_verify_flags_minimaldata_consensus_0731991c73947514())340 return swig_r341}342var Verify_flags_minimaldata LibbitcoinConsensusVerify_flags_type = _swig_getverify_flags_minimaldata()343func _swig_getverify_flags_discourage_upgradable_nops() (_swig_ret LibbitcoinConsensusVerify_flags_type) {344 var swig_r LibbitcoinConsensusVerify_flags_type345 swig_r = (LibbitcoinConsensusVerify_flags_type)(C._wrap_verify_flags_discourage_upgradable_nops_consensus_0731991c73947514())346 return swig_r347}348var Verify_flags_discourage_upgradable_nops LibbitcoinConsensusVerify_flags_type = _swig_getverify_flags_discourage_upgradable_nops()349func _swig_getverify_flags_cleanstack() (_swig_ret LibbitcoinConsensusVerify_flags_type) {350 var swig_r LibbitcoinConsensusVerify_flags_type351 swig_r = (LibbitcoinConsensusVerify_flags_type)(C._wrap_verify_flags_cleanstack_consensus_0731991c73947514())352 return swig_r353}354var Verify_flags_cleanstack LibbitcoinConsensusVerify_flags_type = _swig_getverify_flags_cleanstack()355func _swig_getverify_flags_checklocktimeverify() (_swig_ret LibbitcoinConsensusVerify_flags_type) {356 var swig_r LibbitcoinConsensusVerify_flags_type357 swig_r = (LibbitcoinConsensusVerify_flags_type)(C._wrap_verify_flags_checklocktimeverify_consensus_0731991c73947514())358 return swig_r359}360var Verify_flags_checklocktimeverify LibbitcoinConsensusVerify_flags_type = _swig_getverify_flags_checklocktimeverify()361func Verify_script(arg1 *byte, arg2 int64, arg3 *byte, arg4 int64, arg5 uint, arg6 uint) (_swig_ret LibbitcoinConsensusVerify_result_type) {362 var swig_r LibbitcoinConsensusVerify_result_type363 _swig_i_0 := arg1364 _swig_i_1 := arg2365 _swig_i_2 := arg3366 _swig_i_3 := arg4367 _swig_i_4 := arg5368 _swig_i_5 := arg6369 swig_r = (LibbitcoinConsensusVerify_result_type)(C._wrap_verify_script_consensus_0731991c73947514(C.swig_voidp(_swig_i_0), C.swig_type_1(_swig_i_1), C.swig_voidp(_swig_i_2), C.swig_type_2(_swig_i_3), C.swig_intgo(_swig_i_4), C.swig_intgo(_swig_i_5)))370 return swig_r371}...

Full Screen

Full Screen

Operators.swift

Source:Operators.swift Github

copy

Full Screen

...7import Foundation8public typealias Op = Operator9public typealias Operator = SwifQLPartOperator10extension SwifQLPartOperator {11 public typealias Result = SwifQLPartOperator12 13 public static var left: Result { "LEFT".operator }14 public static var right: Result { "RIGHT".operator }15 public static var inner: Result { "INNER".operator }16 public static var outer: Result { "OUTER".operator }17 public static var cross: Result { "CROSS".operator }18 public static var lateral: Result { "LATERAL".operator }19 public static var action: Result { "ACTION".operator }20 public static var no: Result { "NO".operator }21 public static var references: Result { "REFERENCES".operator }22 public static var check: Result { "CHECK".operator }23 public static var add: Result { "ADD".operator }24 public static var primary: Result { "PRIMARY".operator }25 public static var key: Result { "KEY".operator }26 public static var unique: Result { "UNIQUE".operator }27 public static var select: Result { "SELECT".operator }28 public static var distinct: Result { "DISTINCT".operator }29 public static var `as`: Result { "as".operator }30 public static var any: Result { "ANY".operator }31 public static var delete: Result { "DELETE".operator }32 public static var from: Result { "FROM".operator }33 public static var join: Result { "JOIN".operator }34 public static var `where`: Result { "WHERE".operator }35 public static var having: Result { "HAVING".operator }36 public static var group: Result { "GROUP".operator }37 public static var order: Result { "ORDER".operator }38 public static var by: Result { "BY".operator }39 public static var insert: Result { "INSERT".operator }40 public static var into: Result { "INTO".operator }41 public static var values: Result { "VALUES".operator }42 public static var union: Result { "UNION".operator }43 public static var all: Result { "ALL".operator }44 public static var returning: Result { "RETURNING".operator }45 public static var exists: Result { "EXISTS".operator }46 public static var and: Result { "AND".operator }47 public static var or: Result { "OR".operator }48 public static var greaterThan: Result { ">".operator }49 public static var lessThan: Result { "<".operator }50 public static var greaterThanOrEqual: Result { ">=".operator }51 public static var lessThanOrEqual: Result { "<=".operator }52 public static var equal: Result { "=".operator }53 public static var notEqual: Result { "!=".operator }54 public static var `if`: Result { "IF".operator }55 public static var `in`: Result { "IN".operator }56 public static var notIn: Result { "NOT IN".operator }57 public static var like: Result { "LIKE".operator }58 public static var notLike: Result { "NOT LIKE".operator }59 public static var ilike: Result { "ILIKE".operator }60 public static var notILike: Result { "NOT ILIKE".operator }61 public static var fulltext: Result { "@@".operator }62 public static var isNull: Result { "IS NULL".operator }63 public static var isNotNull: Result { "IS NOT NULL".operator }64 public static var contains: Result { "@>".operator }65 public static var containedBy: Result { "<@".operator }66 public static var on: Result { "ON".operator }67 public static var `case`: Result { "CASE".operator }68 public static var when: Result { "WHEN".operator }69 public static var then: Result { "THEN".operator }70 public static var `else`: Result { "ELSE".operator }71 public static var end: Result { "END".operator }72 public static var null: Result { "NULL".operator }73 public static var `do`: Result { "DO".operator }74 public static var conflict: Result { "CONFLICT".operator }75 public static var constraint: Result { "CONSTRAINT".operator }76 public static var nothing: Result { "NOTHING".operator }77 public static var asc: Result { "ASC".operator }78 public static var desc: Result { "DESC".operator }79 public static var limit: Result { "LIMIT".operator }80 public static var offset: Result { "OFFSET".operator }81 public static var `for`: Result { "FOR".operator }82 public static var filter: Result { "FILTER".operator }83 public static var array: Result { "ARRAY".operator }84 public static var doubleDollar: Result { "$$".operator }85 public static var between: Result { "BETWEEN".operator }86 public static var notBetween: Result { "NOT BETWEEN".operator }87 public static var not: Result { "NOT".operator }88 public static var timestamp: Result { "TIMESTAMP".operator }89 public static var with: Result { "WITH".operator }90 public static var timeZone: Result { "TIME ZONE".operator }91 public static var epoch: Result { "EPOCH".operator }92 public static var interval: Result { "INTERVAL".operator }93 public static var date: Result { "DATE".operator }94 public static var millenium: Result { "MILLENNIUM".operator }95 public static var microseconds: Result { "MICROSECONDS".operator }96 public static var milliseconds: Result { "MILLISECONDS".operator }97 public static var isoYear: Result { "ISOYEAR".operator }98 public static var isoDoW: Result { "ISODOW".operator }99 public static var hour: Result { "HOUR".operator }100 public static var time: Result { "TIME".operator }101 public static var minute: Result { "MINUTE".operator }102 public static var month: Result { "MONTH".operator }103 public static var quarter: Result { "QUARTER".operator }104 public static var second: Result { "SECOND".operator }105 public static var week: Result { "WEEK".operator }106 public static var year: Result { "YEAR".operator }107 public static var decade: Result { "DECADE".operator }108 public static var century: Result { "CENTURY".operator }109 public static var overlaps: Result { "OVERLAPS".operator }110 public static var over: Result { "OVER".operator }111 public static var doublePrecision: Result { "DOUBLE PRECISION".operator }112 public static var nulls: Result { "NULLS".operator }113 public static var first: Result { "FIRST".operator }114 public static var last: Result { "LAST".operator }115 public static var create: Result { "CREATE".operator }116 public static var index: Result { "INDEX".operator }117 public static var type: Result { "TYPE".operator }118 public static var function: Result { "FUNCTION".operator }119 public static var table: Result { "TABLE".operator }120 public static var `enum`: Result { "ENUM".operator }121 public static var range: Result { "RANGE".operator }122 public static var subtype: Result { "SUBTYPE".operator }123 public static var subtypeOpClass: Result { "SUBTYPE_OPCLASS".operator }124 public static var collate: Result { "COLLATE".operator }125 public static var collation: Result { "COLLATION".operator }126 public static var collatable: Result { "COLLATABLE".operator }127 public static var canonical: Result { "CANONICAL".operator }128 public static var subtypeDiff: Result { "SUBTYPE_DIFF".operator }129 public static var input: Result { "INPUT".operator }130 public static var output: Result { "OUTPUT".operator }131 public static var receive: Result { "RECEIVE".operator }132 public static var send: Result { "SEND".operator }133 public static var typmodIn: Result { "TYPMOD_IN".operator }134 public static var typmodOut: Result { "TYPMOD_OUT".operator }135 public static var analyze: Result { "ANALYZE".operator }136 public static var internalLength: Result { "INTERNALLENGTH".operator }137 public static var variable: Result { "VARIABLE".operator }138 public static var passedByValue: Result { "PASSEDBYVALUE".operator }139 public static var alignment: Result { "ALIGNMENT".operator }140 public static var storage: Result { "STORAGE".operator }141 public static var category: Result { "CATEGORY".operator }142 public static var preferred: Result { "PREFERRED".operator }143 public static var `default`: Result { "DEFAULT".operator }144 public static var element: Result { "ELEMENT".operator }145 public static var delimiter: Result { "DELIMITER".operator }146 public static var returns: Result { "RETURNS".operator }147 public static var setOf: Result { "SETOF".operator }148 public static var begin: Result { "BEGIN".operator }149 public static var commit: Result { "COMMIT".operator }150 public static var rollback: Result { "ROLLBACK".operator }151 public static var `return`: Result { "RETURN".operator }152 public static var raise: Result { "RAISE".operator }153 public static var exception: Result { "EXCEPTION".operator }154 public static var replace: Result { "REPLACE".operator }155 public static var semicolon: Result { ";".operator }156 public static var openBracket: Result { "(".operator }157 public static var closeBracket: Result { ")".operator }158 public static var openSquareBracket: Result { "[".operator }159 public static var closeSquareBracket: Result { "]".operator }160 public static var openBrace: Result { "{".operator }161 public static var closeBrace: Result { "}".operator }162 public static var comma: Result { ",".operator }163 public static var period: Result { ".".operator }164 public static var space: Result { `_` }165 public static var `_`: Result { " ".operator }166 public static var using: Result { "USING".operator }167 public static var owner: Result { "OWNER".operator }168 public static var to: Result { "TO".operator }169 public static var currentUser: Result { "CURRENT_USER".operator }170 public static var sessionUser: Result { "SESSION_USER".operator }171 public static var rename: Result { "RENAME".operator }172 public static var column: Result { "COLUMN".operator }173 public static var attribute: Result { "ATTRIBUTE".operator }174 public static var cascade: Result { "CASCADE".operator }175 public static var restrict: Result { "RESTRICT".operator }176 public static var schema: Result { "SCHEMA".operator }177 public static var foreign: Result { "FOREIGN".operator }178 public static var value: Result { "VALUE".operator }179 public static var before: Result { "BEFORE".operator }180 public static var after: Result { "AFTER".operator }181 public static var drop: Result { "DROP".operator }182 public static var update: Result { "UPDATE".operator }183 public static var alter: Result { "ALTER".operator }184 public static var set: Result { "SET".operator }185 public static var data: Result { "DATA".operator }186 public static var partition: Result { "PARTITION".operator }187 public static var window: Result { "WINDOW".operator }188 public static func custom(_ v: String) -> Result { v.operator }189 190 public var left: Result { concatWith(.left) }191 public var right: Result { concatWith(.right) }192 public var inner: Result { concatWith(.inner) }193 public var outer: Result { concatWith(.outer) }194 public var cross: Result { concatWith(.cross) }195 public var lateral: Result { concatWith(.lateral) }196 public var no: Result { concatWith(.no) }197 public var action: Result { concatWith(.action) }198 public var references: Result { concatWith(.references) }199 public var add: Result { concatWith(.add) }200 public var check: Result { concatWith(.check) }201 public var primary: Result { concatWith(.primary) }202 public var key: Result { concatWith(.key) }203 public var unique: Result { concatWith(.unique) }204 public var select: Result { concatWith(.select) }205 public var distinct: Result { concatWith(.distinct) }206 public var `as`: Result { concatWith(.as) }207 public var any: Result { concatWith(.any) }208 public var delete: Result { concatWith(.delete) }209 public var from: Result { concatWith(.from) }210 public var join: Result { concatWith(.join) }211 public var `where`: Result { concatWith(.where) }212 public var having: Result { concatWith(.having) }213 public var group: Result { concatWith(.group) }214 public var order: Result { concatWith(.order) }215 public var by: Result { concatWith(.by) }216 public var insert: Result { concatWith(.insert) }217 public var into: Result { concatWith(.into) }218 public var values: Result { concatWith(.values) }219 public var union: Result { concatWith(.union) }220 public var returning: Result { concatWith(.returning) }221 public var exists: Result { concatWith(.exists) }222 public var and: Result { concatWith(.and) }223 public var or: Result { concatWith(.or) }224 public var greaterThan: Result { concatWith(.greaterThan) }225 public var lessThan: Result { concatWith(.lessThan) }226 public var greaterThanOrEqual: Result { concatWith(.greaterThanOrEqual) }227 public var lessThanOrEqual: Result { concatWith(.lessThanOrEqual) }228 public var equal: Result { concatWith(.equal) }229 public var notEqual: Result { concatWith(.notEqual) }230 public var `if`: Result { concatWith(.if) }231 public var `in`: Result { concatWith(.in) }232 public var notIn: Result { concatWith(.notIn) }233 public var like: Result { concatWith(.like) }234 public var notLike: Result { concatWith(.notLike) }235 public var ilike: Result { concatWith(.ilike) }236 public var notILike: Result { concatWith(.notILike) }237 public var fulltext: Result { concatWith(.fulltext) }238 public var isNull: Result { concatWith(.isNull) }239 public var isNotNull: Result { concatWith(.isNotNull) }240 public var contains: Result { concatWith(.contains) }241 public var containedBy: Result { concatWith(.containedBy) }242 public var on: Result { concatWith(.on) }243 public var `case`: Result { concatWith(.case) }244 public var when: Result { concatWith(.when) }245 public var then: Result { concatWith(.then) }246 public var `else`: Result { concatWith(.else) }247 public var end: Result { concatWith(.end) }248 public var null: Result { concatWith(.null) }249 public var `do`: Result { concatWith(.do) }250 public var conflict: Result { concatWith(.conflict) }251 public var constraint: Result { concatWith(.constraint) }252 public var nothing: Result { concatWith(.nothing) }253 public var asc: Result { concatWith(.asc) }254 public var desc: Result { concatWith(.desc) }255 public var limit: Result { concatWith(.limit) }256 public var offset: Result { concatWith(.offset) }257 public var `for`: Result { concatWith(.for) }258 public var filter: Result { concatWith(.filter) }259 public var array: Result { concatWith(.array) }260 public var doubleDollar: Result { concatWith(.doubleDollar) }261 public var between: Result { concatWith(.between) }262 public var notBetween: Result { concatWith(.notBetween) }263 public var not: Result { concatWith(.not) }264 public var timestamp: Result { concatWith(.timestamp) }265 public var with: Result { concatWith(.with) }266 public var timeZone: Result { concatWith(.timeZone) }267 public var epoch: Result { concatWith(.epoch) }268 public var interval: Result { concatWith(.interval) }269 public var date: Result { concatWith(.date) }270 public var millenium: Result { concatWith(.millenium) }271 public var microseconds: Result { concatWith(.microseconds) }272 public var milliseconds: Result { concatWith(.milliseconds) }273 public var isoYear: Result { concatWith(.isoYear) }274 public var isoDoW: Result { concatWith(.isoDoW) }275 public var hour: Result { concatWith(.hour) }276 public var time: Result { concatWith(.time) }277 public var minute: Result { concatWith(.minute) }278 public var month: Result { concatWith(.month) }279 public var quarter: Result { concatWith(.quarter) }280 public var second: Result { concatWith(.second) }281 public var week: Result { concatWith(.week) }282 public var year: Result { concatWith(.year) }283 public var decade: Result { concatWith(.decade) }284 public var century: Result { concatWith(.century) }285 public var overlaps: Result { concatWith(.overlaps) }286 public var over: Result { concatWith(.over) }287 public var doublePrecision: Result { concatWith(.doublePrecision) }288 public var nulls: Result { concatWith(.nulls) }289 public var first: Result { concatWith(.first) }290 public var last: Result { concatWith(.last) }291 public var create: Result { concatWith(.create) }292 public var index: Result { concatWith(.index) }293 public var type: Result { concatWith(.type) }294 public var function: Result { concatWith(.function) }295 public var table: Result { concatWith(.table) }296 public var `enum`: Result { concatWith(.enum) }297 public var range: Result { concatWith(.range) }298 public var subtype: Result { concatWith(.subtype) }299 public var subtypeOpClass: Result { concatWith(.subtypeOpClass) }300 public var collate: Result { concatWith(.collate) }301 public var collation: Result { concatWith(.collation) }302 public var collatable: Result { concatWith(.collatable) }303 public var canonical: Result { concatWith(.canonical) }304 public var subtypeDiff: Result { concatWith(.subtypeDiff) }305 public var input: Result { concatWith(.input) }306 public var output: Result { concatWith(.output) }307 public var receive: Result { concatWith(.receive) }308 public var send: Result { concatWith(.send) }309 public var typmodIn: Result { concatWith(.typmodIn) }310 public var typmodOut: Result { concatWith(.typmodOut) }311 public var analyze: Result { concatWith(.analyze) }312 public var internalLength: Result { concatWith(.internalLength) }313 public var variable: Result { concatWith(.variable) }314 public var passedByValue: Result { concatWith(.passedByValue) }315 public var alignment: Result { concatWith(.alignment) }316 public var storage: Result { concatWith(.storage) }317 public var category: Result { concatWith(.category) }318 public var preferred: Result { concatWith(.preferred) }319 public var `default`: Result { concatWith(.default) }320 public var element: Result { concatWith(.element) }321 public var delimiter: Result { concatWith(.delimiter) }322 public var returns: Result { concatWith(.returns) }323 public var setOf: Result { concatWith(.setOf) }324 public var begin: Result { concatWith(.begin) }325 public var commit: Result { concatWith(.commit) }326 public var rollback: Result { concatWith(.rollback) }327 public var `return`: Result { concatWith(.return) }328 public var raise: Result { concatWith(.raise) }329 public var exception: Result { concatWith(.exception) }330 public var replace: Result { concatWith(.replace) }331 public var semicolon: Result { concatWith(.semicolon) }332 public var openBracket: Result { concatWith(.openBracket) }333 public var closeBracket: Result { concatWith(.closeBracket) }334 public var openSquareBracket: Result { concatWith(.openSquareBracket) }335 public var closeSquareBracket: Result { concatWith(.closeSquareBracket) }336 public var openBrace: Result { concatWith(.openBrace) }337 public var closeBrace: Result { concatWith(.closeBrace) }338 public var comma: Result { concatWith(.comma) }339 public var period: Result { concatWith(.period) }340 public var space: Result { concatWith(.space) }341 public var `_`: Result { concatWith(._) }342 public var using: Result { concatWith(.using) }343 public var owner: Result { concatWith(.owner) }344 public var to: Result { concatWith(.to) }345 public var currentUser: Result { concatWith(.currentUser) }346 public var sessionUser: Result { concatWith(.sessionUser) }347 public var rename: Result { concatWith(.rename) }348 public var column: Result { concatWith(.column) }349 public var attribute: Result { concatWith(.attribute) }350 public var cascade: Result { concatWith(.cascade) }351 public var restrict: Result { concatWith(.restrict) }352 public var schema: Result { concatWith(.schema) }353 public var foreign: Result { concatWith(.foreign) }354 public var value: Result { concatWith(.value) }355 public var before: Result { concatWith(.before) }356 public var after: Result { concatWith(.after) }357 public var drop: Result { concatWith(.drop) }358 public var update: Result { concatWith(.update) }359 public var alter: Result { concatWith(.alter) }360 public var set: Result { concatWith(.set) }361 public var data: Result { concatWith(.data) }362 public var partition: Result { concatWith(.partition) }363 public var window: Result { concatWith(.window) }364 public func custom(_ v: String) -> Result { concatWith(.custom(v)) }365 366 private func concatWith(_ operator: Result) -> Result {367 (_value + `operator`._value).operator368 }369}370extension String {371 fileprivate var `operator`: SwifQLPartOperator { .init(self) }372}...

Full Screen

Full Screen

ResultTests.swift

Source:ResultTests.swift Github

copy

Full Screen

1//2// ResultTests.swift3//4// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)5//6// Permission is hereby granted, free of charge, to any person obtaining a copy7// of this software and associated documentation files (the "Software"), to deal8// in the Software without restriction, including without limitation the rights9// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell10// copies of the Software, and to permit persons to whom the Software is11// furnished to do so, subject to the following conditions:12//13// The above copyright notice and this permission notice shall be included in14// all copies or substantial portions of the Software.15//16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE19// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,21// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN22// THE SOFTWARE.23//24@testable import Alamofire25import Foundation26import XCTest27class ResultTestCase: BaseTestCase {28 let error = AFError.responseValidationFailed(reason: .unacceptableStatusCode(code: 404))29 // MARK: - Is Success Tests30 func testThatIsSuccessPropertyReturnsTrueForSuccessCase() {31 // Given, When32 let result = Result<String>.success("success")33 // Then34 XCTAssertTrue(result.isSuccess, "result is success should be true for success case")35 }36 func testThatIsSuccessPropertyReturnsFalseForFailureCase() {37 // Given, When38 let result = Result<String>.failure(error)39 // Then40 XCTAssertFalse(result.isSuccess, "result is success should be false for failure case")41 }42 // MARK: - Is Failure Tests43 func testThatIsFailurePropertyReturnsFalseForSuccessCase() {44 // Given, When45 let result = Result<String>.success("success")46 // Then47 XCTAssertFalse(result.isFailure, "result is failure should be false for success case")48 }49 func testThatIsFailurePropertyReturnsTrueForFailureCase() {50 // Given, When51 let result = Result<String>.failure(error)52 // Then53 XCTAssertTrue(result.isFailure, "result is failure should be true for failure case")54 }55 // MARK: - Value Tests56 func testThatValuePropertyReturnsValueForSuccessCase() {57 // Given, When58 let result = Result<String>.success("success")59 // Then60 XCTAssertEqual(result.value ?? "", "success", "result value should match expected value")61 }62 func testThatValuePropertyReturnsNilForFailureCase() {63 // Given, When64 let result = Result<String>.failure(error)65 // Then66 XCTAssertNil(result.value, "result value should be nil for failure case")67 }68 // MARK: - Error Tests69 func testThatErrorPropertyReturnsNilForSuccessCase() {70 // Given, When71 let result = Result<String>.success("success")72 // Then73 XCTAssertNil(result.error, "result error should be nil for success case")74 }75 func testThatErrorPropertyReturnsErrorForFailureCase() {76 // Given, When77 let result = Result<String>.failure(error)78 // Then79 XCTAssertNotNil(result.error, "result error should not be nil for failure case")80 }81 // MARK: - Description Tests82 func testThatDescriptionStringMatchesExpectedValueForSuccessCase() {83 // Given, When84 let result = Result<String>.success("success")85 // Then86 XCTAssertEqual(result.description, "SUCCESS", "result description should match expected value for success case")87 }88 func testThatDescriptionStringMatchesExpectedValueForFailureCase() {89 // Given, When90 let result = Result<String>.failure(error)91 // Then92 XCTAssertEqual(result.description, "FAILURE", "result description should match expected value for failure case")93 }94 // MARK: - Debug Description Tests95 func testThatDebugDescriptionStringMatchesExpectedValueForSuccessCase() {96 // Given, When97 let result = Result<String>.success("success value")98 // Then99 XCTAssertEqual(100 result.debugDescription,101 "SUCCESS: success value",102 "result debug description should match expected value for success case"103 )104 }105 func testThatDebugDescriptionStringMatchesExpectedValueForFailureCase() {106 // Given, When107 let result = Result<String>.failure(error)108 // Then109 XCTAssertEqual(110 result.debugDescription,111 "FAILURE: \(error)",112 "result debug description should match expected value for failure case"113 )114 }115 // MARK: - Initializer Tests116 func testThatInitializerFromThrowingClosureStoresResultAsASuccess() {117 // Given118 let value = "success value"119 // When120 let result1 = Result(value: { value })121 let result2 = Result { value }122 // Then123 for result in [result1, result2] {124 XCTAssertTrue(result.isSuccess)125 XCTAssertEqual(result.value, value)126 }127 }128 func testThatInitializerFromThrowingClosureCatchesErrorAsAFailure() {129 // Given130 struct ResultError: Error {}131 // When132 let result1 = Result(value: { throw ResultError() })133 let result2 = Result { throw ResultError() }134 // Then135 for result in [result1, result2] {136 XCTAssertTrue(result.isFailure)137 XCTAssertTrue(result.error! is ResultError)138 }139 }140 // MARK: - Unwrap Tests141 func testThatUnwrapReturnsSuccessValue() {142 // Given143 let result = Result<String>.success("success value")144 // When145 let unwrappedValue = try? result.unwrap()146 // Then147 XCTAssertEqual(unwrappedValue, "success value")148 }149 func testThatUnwrapThrowsFailureError() {150 // Given151 struct ResultError: Error {}152 // When153 let result = Result<String>.failure(ResultError())154 // Then155 do {156 _ = try result.unwrap()157 XCTFail("result unwrapping should throw the failure error")158 } catch {159 XCTAssertTrue(error is ResultError)160 }161 }162 // MARK: - Map Tests163 func testThatMapTransformsSuccessValue() {164 // Given165 let result = Result<String>.success("success value")166 // When167 let mappedResult = result.map { $0.count }168 // Then169 XCTAssertEqual(mappedResult.value, 13)170 }171 func testThatMapPreservesFailureError() {172 // Given173 struct ResultError: Error {}174 let result = Result<String>.failure(ResultError())175 // When176 let mappedResult = result.map { $0.count }177 // Then178 if let error = mappedResult.error {179 XCTAssertTrue(error is ResultError)180 } else {181 XCTFail("map should preserve the failure error")182 }183 }184 // MARK: - FlatMap Tests185 func testThatFlatMapTransformsSuccessValue() {186 // Given187 let result = Result<String>.success("success value")188 // When189 let mappedResult = result.map { $0.count }190 // Then191 XCTAssertEqual(mappedResult.value, 13)192 }193 func testThatFlatMapCatchesTransformationError() {194 // Given195 struct TransformError: Error {}196 let result = Result<String>.success("success value")197 // When198 let mappedResult = result.flatMap { _ in throw TransformError() }199 // Then200 if let error = mappedResult.error {201 XCTAssertTrue(error is TransformError)202 } else {203 XCTFail("flatMap should catch the transformation error")204 }205 }206 func testThatFlatMapPreservesFailureError() {207 // Given208 struct ResultError: Error {}209 struct TransformError: Error {}210 let result = Result<String>.failure(ResultError())211 // When212 let mappedResult = result.flatMap { _ in throw TransformError() }213 // Then214 if let error = mappedResult.error {215 XCTAssertTrue(error is ResultError)216 } else {217 XCTFail("flatMap should preserve the failure error")218 }219 }220 // MARK: - Error Mapping Tests221 func testMapErrorTransformsErrorValue() {222 // Given223 struct ResultError: Error {}224 struct OtherError: Error { let error: Error }225 let result: Result<String> = .failure(ResultError())226 // When227 let mappedResult = result.mapError { OtherError(error: $0) }228 // Then229 if let error = mappedResult.error {230 XCTAssertTrue(error is OtherError)231 } else {232 XCTFail("mapError should transform error value")233 }234 }235 func testMapErrorPreservesSuccessError() {236 // Given237 struct ResultError: Error {}238 struct OtherError: Error { let error: Error }239 let result: Result<String> = .success("success")240 // When241 let mappedResult = result.mapError { OtherError(error: $0) }242 // Then243 XCTAssertEqual(mappedResult.value, "success")244 }245 func testFlatMapErrorTransformsErrorValue() {246 // Given247 struct ResultError: Error {}248 struct OtherError: Error { let error: Error }249 let result: Result<String> = .failure(ResultError())250 // When251 let mappedResult = result.flatMapError { OtherError(error: $0) }252 // Then253 if let error = mappedResult.error {254 XCTAssertTrue(error is OtherError)255 } else {256 XCTFail("mapError should transform error value")257 }258 }259 func testFlatMapErrorCapturesThrownError() {260 // Given261 struct ResultError: Error {}262 struct OtherError: Error {263 let error: Error264 init(error: Error) throws { throw ThrownError() }265 }266 struct ThrownError: Error {}267 let result: Result<String> = .failure(ResultError())268 // When269 let mappedResult = result.flatMapError { try OtherError(error: $0) }270 // Then271 if let error = mappedResult.error {272 XCTAssertTrue(error is ThrownError)273 } else {274 XCTFail("mapError should capture thrown error value")275 }276 }277 // MARK: - With Value or Error Tests278 func testWithValueExecutesWhenSuccess() {279 // Given280 let result: Result<String> = .success("success")281 var string = "failure"282 // When283 result.withValue { string = $0 }284 // Then285 XCTAssertEqual(string, "success")286 }287 func testWithValueDoesNotExecutesWhenFailure() {288 // Given289 struct ResultError: Error {}290 let result: Result<String> = .failure(ResultError())291 var string = "failure"292 // When293 result.withValue { string = $0 }294 // Then295 XCTAssertEqual(string, "failure")296 }297 func testWithErrorExecutesWhenFailure() {298 // Given299 struct ResultError: Error {}300 let result: Result<String> = .failure(ResultError())301 var string = "success"302 // When303 result.withError { string = "\(type(of: $0))" }304 // Then305 XCTAssertEqual(string, "ResultError")306 }307 func testWithErrorDoesNotExecuteWhenSuccess() {308 // Given309 let result: Result<String> = .success("success")310 var string = "success"311 // When312 result.withError { string = "\(type(of: $0))" }313 // Then314 XCTAssertEqual(string, "success")315 }316 // MARK: - If Success or Failure Tests317 func testIfSuccessExecutesWhenSuccess() {318 // Given319 let result: Result<String> = .success("success")320 var string = "failure"321 // When322 result.ifSuccess { string = "success" }323 // Then324 XCTAssertEqual(string, "success")325 }326 func testIfSuccessDoesNotExecutesWhenFailure() {327 // Given328 struct ResultError: Error {}329 let result: Result<String> = .failure(ResultError())330 var string = "failure"331 // When332 result.ifSuccess { string = "success" }333 // Then334 XCTAssertEqual(string, "failure")335 }336 func testIfFailureExecutesWhenFailure() {337 // Given338 struct ResultError: Error {}339 let result: Result<String> = .failure(ResultError())340 var string = "success"341 // When342 result.ifFailure { string = "failure" }343 // Then344 XCTAssertEqual(string, "failure")345 }346 func testIfFailureDoesNotExecuteWhenSuccess() {347 // Given348 let result: Result<String> = .success("success")349 var string = "success"350 // When351 result.ifFailure { string = "failure" }352 // Then353 XCTAssertEqual(string, "success")354 }355 // MARK: - Functional Chaining Tests356 func testFunctionalMethodsCanBeChained() {357 // Given358 struct ResultError: Error {}359 let result: Result<String> = .success("first")360 var string = "first"361 var success = false362 // When363 let endResult = result364 .map { _ in "second" }365 .flatMap { _ in "third" }366 .withValue { if $0 == "third" { string = "fourth" } }367 .ifSuccess { success = true }368 // Then369 XCTAssertEqual(endResult.value, "third")370 XCTAssertEqual(string, "fourth")371 XCTAssertTrue(success)372 }373}...

Full Screen

Full Screen

pow_basic_64bit.phpt

Source:pow_basic_64bit.phpt Github

copy

Full Screen

...36 -2147483648);37foreach($bases as $base) {38 echo "\n\nBase = $base";39 foreach($exponents as $exponent) {40 echo "\n..... Exponent = $exponent Result = ";41 $res = pow($base, $exponent);42 echo $res;43 }44 echo "\n\n";45}46?>47--EXPECT--48Base = 2349..... Exponent = 0 Result = 150..... Exponent = 1 Result = 2351..... Exponent = -1 Result = 0.04347826086956552..... Exponent = 2 Result = 52953..... Exponent = -2 Result = 0.00189035916824254..... Exponent = 3 Result = 1216755..... Exponent = -3 Result = 8.2189529053999E-556..... Exponent = 2.5 Result = 2536.994875832457..... Exponent = -2.5 Result = 0.0003941671343233958..... Exponent = 500 Result = INF59..... Exponent = -500 Result = 060..... Exponent = 2147483647 Result = INF61..... Exponent = -2147483648 Result = 062Base = -2363..... Exponent = 0 Result = 164..... Exponent = 1 Result = -2365..... Exponent = -1 Result = -0.04347826086956566..... Exponent = 2 Result = 52967..... Exponent = -2 Result = 0.00189035916824268..... Exponent = 3 Result = -1216769..... Exponent = -3 Result = -8.2189529053999E-570..... Exponent = 2.5 Result = NAN71..... Exponent = -2.5 Result = NAN72..... Exponent = 500 Result = INF73..... Exponent = -500 Result = 074..... Exponent = 2147483647 Result = -INF75..... Exponent = -2147483648 Result = 076Base = 23.177..... Exponent = 0 Result = 178..... Exponent = 1 Result = 23.179..... Exponent = -1 Result = 0.04329004329004380..... Exponent = 2 Result = 533.6181..... Exponent = -2 Result = 0.001874027848053882..... Exponent = 3 Result = 12326.39183..... Exponent = -3 Result = 8.1126746668997E-584..... Exponent = 2.5 Result = 2564.660894057985..... Exponent = -2.5 Result = 0.0003899150965014186..... Exponent = 500 Result = INF87..... Exponent = -500 Result = 088..... Exponent = 2147483647 Result = INF89..... Exponent = -2147483648 Result = 090Base = -23.191..... Exponent = 0 Result = 192..... Exponent = 1 Result = -23.193..... Exponent = -1 Result = -0.04329004329004394..... Exponent = 2 Result = 533.6195..... Exponent = -2 Result = 0.001874027848053896..... Exponent = 3 Result = -12326.39197..... Exponent = -3 Result = -8.1126746668997E-598..... Exponent = 2.5 Result = NAN99..... Exponent = -2.5 Result = NAN100..... Exponent = 500 Result = INF101..... Exponent = -500 Result = 0102..... Exponent = 2147483647 Result = -INF103..... Exponent = -2147483648 Result = 0104Base = 23.45105..... Exponent = 0 Result = 1106..... Exponent = 1 Result = 23.45107..... Exponent = -1 Result = 0.042643923240938108..... Exponent = 2 Result = 549.9025109..... Exponent = -2 Result = 0.001818504189379110..... Exponent = 3 Result = 12895.213625111..... Exponent = -3 Result = 7.7548153065204E-5112..... Exponent = 2.5 Result = 2662.9138571162113..... Exponent = -2.5 Result = 0.00037552848257846114..... Exponent = 500 Result = INF115..... Exponent = -500 Result = 0116..... Exponent = 2147483647 Result = INF117..... Exponent = -2147483648 Result = 0118Base = -23.45119..... Exponent = 0 Result = 1120..... Exponent = 1 Result = -23.45121..... Exponent = -1 Result = -0.042643923240938122..... Exponent = 2 Result = 549.9025123..... Exponent = -2 Result = 0.001818504189379124..... Exponent = 3 Result = -12895.213625125..... Exponent = -3 Result = -7.7548153065204E-5126..... Exponent = 2.5 Result = NAN127..... Exponent = -2.5 Result = NAN128..... Exponent = 500 Result = INF129..... Exponent = -500 Result = 0130..... Exponent = 2147483647 Result = -INF131..... Exponent = -2147483648 Result = 0132Base = 23133..... Exponent = 0 Result = 1134..... Exponent = 1 Result = 23135..... Exponent = -1 Result = 0.043478260869565136..... Exponent = 2 Result = 529137..... Exponent = -2 Result = 0.001890359168242138..... Exponent = 3 Result = 12167139..... Exponent = -3 Result = 8.2189529053999E-5140..... Exponent = 2.5 Result = 2536.9948758324141..... Exponent = -2.5 Result = 0.00039416713432339142..... Exponent = 500 Result = INF143..... Exponent = -500 Result = 0144..... Exponent = 2147483647 Result = INF145..... Exponent = -2147483648 Result = 0146Base = 23147..... Exponent = 0 Result = 1148..... Exponent = 1 Result = 23149..... Exponent = -1 Result = 0.043478260869565150..... Exponent = 2 Result = 529151..... Exponent = -2 Result = 0.001890359168242152..... Exponent = 3 Result = 12167153..... Exponent = -3 Result = 8.2189529053999E-5154..... Exponent = 2.5 Result = 2536.9948758324155..... Exponent = -2.5 Result = 0.00039416713432339156..... Exponent = 500 Result = INF157..... Exponent = -500 Result = 0158..... Exponent = 2147483647 Result = INF159..... Exponent = -2147483648 Result = 0160Base = 23161..... Exponent = 0 Result = 1162..... Exponent = 1 Result = 23163..... Exponent = -1 Result = 0.043478260869565164..... Exponent = 2 Result = 529165..... Exponent = -2 Result = 0.001890359168242166..... Exponent = 3 Result = 12167167..... Exponent = -3 Result = 8.2189529053999E-5168..... Exponent = 2.5 Result = 2536.9948758324169..... Exponent = -2.5 Result = 0.00039416713432339170..... Exponent = 500 Result = INF171..... Exponent = -500 Result = 0172..... Exponent = 2147483647 Result = INF173..... Exponent = -2147483648 Result = 0174Base = 23.45175..... Exponent = 0 Result = 1176..... Exponent = 1 Result = 23.45177..... Exponent = -1 Result = 0.042643923240938178..... Exponent = 2 Result = 549.9025179..... Exponent = -2 Result = 0.001818504189379180..... Exponent = 3 Result = 12895.213625181..... Exponent = -3 Result = 7.7548153065204E-5182..... Exponent = 2.5 Result = 2662.9138571162183..... Exponent = -2.5 Result = 0.00037552848257846184..... Exponent = 500 Result = INF185..... Exponent = -500 Result = 0186..... Exponent = 2147483647 Result = INF187..... Exponent = -2147483648 Result = 0188Base = 2.345e1189..... Exponent = 0 Result = 1190..... Exponent = 1 Result = 23.45191..... Exponent = -1 Result = 0.042643923240938192..... Exponent = 2 Result = 549.9025193..... Exponent = -2 Result = 0.001818504189379194..... Exponent = 3 Result = 12895.213625195..... Exponent = -3 Result = 7.7548153065204E-5196..... Exponent = 2.5 Result = 2662.9138571162197..... Exponent = -2.5 Result = 0.00037552848257846198..... Exponent = 500 Result = INF199..... Exponent = -500 Result = 0200..... Exponent = 2147483647 Result = INF201..... Exponent = -2147483648 Result = 0202Base = 9223372036854775807203..... Exponent = 0 Result = 1204..... Exponent = 1 Result = 9223372036854775807205..... Exponent = -1 Result = 1.0842021724855E-19206..... Exponent = 2 Result = 8.5070591730235E+37207..... Exponent = -2 Result = 1.1754943508223E-38208..... Exponent = 3 Result = 7.8463771692334E+56209..... Exponent = -3 Result = 1.274473528906E-57210..... Exponent = 2.5 Result = 2.5835942961798E+47211..... Exponent = -2.5 Result = 3.8705767444936E-48212..... Exponent = 500 Result = INF213..... Exponent = -500 Result = 0214..... Exponent = 2147483647 Result = INF215..... Exponent = -2147483648 Result = 0216Base = -9223372036854775808217..... Exponent = 0 Result = 1218..... Exponent = 1 Result = -9223372036854775808219..... Exponent = -1 Result = -1.0842021724855E-19220..... Exponent = 2 Result = 8.5070591730235E+37221..... Exponent = -2 Result = 1.1754943508223E-38222..... Exponent = 3 Result = -7.8463771692334E+56223..... Exponent = -3 Result = -1.274473528906E-57224..... Exponent = 2.5 Result = NAN225..... Exponent = -2.5 Result = NAN226..... Exponent = 500 Result = INF227..... Exponent = -500 Result = 0228..... Exponent = 2147483647 Result = -INF229..... Exponent = -2147483648 Result = 0...

Full Screen

Full Screen

pow_basic.phpt

Source:pow_basic.phpt Github

copy

Full Screen

...36 -2147483648);37foreach($bases as $base) {38 echo "\n\nBase = $base";39 foreach($exponents as $exponent) {40 echo "\n..... Exponent = $exponent Result = ";41 $res = pow($base, $exponent);42 echo $res;43 }44 echo "\n\n";45}46?>47--EXPECT--48Base = 2349..... Exponent = 0 Result = 150..... Exponent = 1 Result = 2351..... Exponent = -1 Result = 0.04347826086956552..... Exponent = 2 Result = 52953..... Exponent = -2 Result = 0.00189035916824254..... Exponent = 3 Result = 1216755..... Exponent = -3 Result = 8.2189529053999E-556..... Exponent = 2.5 Result = 2536.994875832457..... Exponent = -2.5 Result = 0.0003941671343233958..... Exponent = 500 Result = INF59..... Exponent = -500 Result = 060..... Exponent = 2147483647 Result = INF61..... Exponent = -2147483648 Result = 062Base = -2363..... Exponent = 0 Result = 164..... Exponent = 1 Result = -2365..... Exponent = -1 Result = -0.04347826086956566..... Exponent = 2 Result = 52967..... Exponent = -2 Result = 0.00189035916824268..... Exponent = 3 Result = -1216769..... Exponent = -3 Result = -8.2189529053999E-570..... Exponent = 2.5 Result = NAN71..... Exponent = -2.5 Result = NAN72..... Exponent = 500 Result = INF73..... Exponent = -500 Result = 074..... Exponent = 2147483647 Result = -INF75..... Exponent = -2147483648 Result = 076Base = 23.177..... Exponent = 0 Result = 178..... Exponent = 1 Result = 23.179..... Exponent = -1 Result = 0.04329004329004380..... Exponent = 2 Result = 533.6181..... Exponent = -2 Result = 0.001874027848053882..... Exponent = 3 Result = 12326.39183..... Exponent = -3 Result = 8.1126746668997E-584..... Exponent = 2.5 Result = 2564.660894057985..... Exponent = -2.5 Result = 0.0003899150965014186..... Exponent = 500 Result = INF87..... Exponent = -500 Result = 088..... Exponent = 2147483647 Result = INF89..... Exponent = -2147483648 Result = 090Base = -23.191..... Exponent = 0 Result = 192..... Exponent = 1 Result = -23.193..... Exponent = -1 Result = -0.04329004329004394..... Exponent = 2 Result = 533.6195..... Exponent = -2 Result = 0.001874027848053896..... Exponent = 3 Result = -12326.39197..... Exponent = -3 Result = -8.1126746668997E-598..... Exponent = 2.5 Result = NAN99..... Exponent = -2.5 Result = NAN100..... Exponent = 500 Result = INF101..... Exponent = -500 Result = 0102..... Exponent = 2147483647 Result = -INF103..... Exponent = -2147483648 Result = 0104Base = 23.45105..... Exponent = 0 Result = 1106..... Exponent = 1 Result = 23.45107..... Exponent = -1 Result = 0.042643923240938108..... Exponent = 2 Result = 549.9025109..... Exponent = -2 Result = 0.001818504189379110..... Exponent = 3 Result = 12895.213625111..... Exponent = -3 Result = 7.7548153065204E-5112..... Exponent = 2.5 Result = 2662.9138571162113..... Exponent = -2.5 Result = 0.00037552848257846114..... Exponent = 500 Result = INF115..... Exponent = -500 Result = 0116..... Exponent = 2147483647 Result = INF117..... Exponent = -2147483648 Result = 0118Base = -23.45119..... Exponent = 0 Result = 1120..... Exponent = 1 Result = -23.45121..... Exponent = -1 Result = -0.042643923240938122..... Exponent = 2 Result = 549.9025123..... Exponent = -2 Result = 0.001818504189379124..... Exponent = 3 Result = -12895.213625125..... Exponent = -3 Result = -7.7548153065204E-5126..... Exponent = 2.5 Result = NAN127..... Exponent = -2.5 Result = NAN128..... Exponent = 500 Result = INF129..... Exponent = -500 Result = 0130..... Exponent = 2147483647 Result = -INF131..... Exponent = -2147483648 Result = 0132Base = 23133..... Exponent = 0 Result = 1134..... Exponent = 1 Result = 23135..... Exponent = -1 Result = 0.043478260869565136..... Exponent = 2 Result = 529137..... Exponent = -2 Result = 0.001890359168242138..... Exponent = 3 Result = 12167139..... Exponent = -3 Result = 8.2189529053999E-5140..... Exponent = 2.5 Result = 2536.9948758324141..... Exponent = -2.5 Result = 0.00039416713432339142..... Exponent = 500 Result = INF143..... Exponent = -500 Result = 0144..... Exponent = 2147483647 Result = INF145..... Exponent = -2147483648 Result = 0146Base = 23147..... Exponent = 0 Result = 1148..... Exponent = 1 Result = 23149..... Exponent = -1 Result = 0.043478260869565150..... Exponent = 2 Result = 529151..... Exponent = -2 Result = 0.001890359168242152..... Exponent = 3 Result = 12167153..... Exponent = -3 Result = 8.2189529053999E-5154..... Exponent = 2.5 Result = 2536.9948758324155..... Exponent = -2.5 Result = 0.00039416713432339156..... Exponent = 500 Result = INF157..... Exponent = -500 Result = 0158..... Exponent = 2147483647 Result = INF159..... Exponent = -2147483648 Result = 0160Base = 23161..... Exponent = 0 Result = 1162..... Exponent = 1 Result = 23163..... Exponent = -1 Result = 0.043478260869565164..... Exponent = 2 Result = 529165..... Exponent = -2 Result = 0.001890359168242166..... Exponent = 3 Result = 12167167..... Exponent = -3 Result = 8.2189529053999E-5168..... Exponent = 2.5 Result = 2536.9948758324169..... Exponent = -2.5 Result = 0.00039416713432339170..... Exponent = 500 Result = INF171..... Exponent = -500 Result = 0172..... Exponent = 2147483647 Result = INF173..... Exponent = -2147483648 Result = 0174Base = 23.45175..... Exponent = 0 Result = 1176..... Exponent = 1 Result = 23.45177..... Exponent = -1 Result = 0.042643923240938178..... Exponent = 2 Result = 549.9025179..... Exponent = -2 Result = 0.001818504189379180..... Exponent = 3 Result = 12895.213625181..... Exponent = -3 Result = 7.7548153065204E-5182..... Exponent = 2.5 Result = 2662.9138571162183..... Exponent = -2.5 Result = 0.00037552848257846184..... Exponent = 500 Result = INF185..... Exponent = -500 Result = 0186..... Exponent = 2147483647 Result = INF187..... Exponent = -2147483648 Result = 0188Base = 2.345e1189..... Exponent = 0 Result = 1190..... Exponent = 1 Result = 23.45191..... Exponent = -1 Result = 0.042643923240938192..... Exponent = 2 Result = 549.9025193..... Exponent = -2 Result = 0.001818504189379194..... Exponent = 3 Result = 12895.213625195..... Exponent = -3 Result = 7.7548153065204E-5196..... Exponent = 2.5 Result = 2662.9138571162197..... Exponent = -2.5 Result = 0.00037552848257846198..... Exponent = 500 Result = INF199..... Exponent = -500 Result = 0200..... Exponent = 2147483647 Result = INF201..... Exponent = -2147483648 Result = 0202Base = 2147483647203..... Exponent = 0 Result = 1204..... Exponent = 1 Result = 2147483647205..... Exponent = -1 Result = 4.6566128752458E-10206..... Exponent = 2 Result = 4.6116860141324E+18207..... Exponent = -2 Result = 2.1684043469905E-19208..... Exponent = 3 Result = 9.903520300448E+27209..... Exponent = -3 Result = 1.0097419600935E-28210..... Exponent = 2.5 Result = 2.1370991100146E+23211..... Exponent = -2.5 Result = 4.6792401686657E-24212..... Exponent = 500 Result = INF213..... Exponent = -500 Result = 0214..... Exponent = 2147483647 Result = INF215..... Exponent = -2147483648 Result = 0216Base = -2147483648217..... Exponent = 0 Result = 1218..... Exponent = 1 Result = -2147483648219..... Exponent = -1 Result = -4.6566128730774E-10220..... Exponent = 2 Result = 4.6116860184274E+18221..... Exponent = -2 Result = 2.168404344971E-19222..... Exponent = 3 Result = -9.903520314283E+27223..... Exponent = -3 Result = -1.0097419586829E-28224..... Exponent = 2.5 Result = NAN225..... Exponent = -2.5 Result = NAN226..... Exponent = 500 Result = INF227..... Exponent = -500 Result = 0228..... Exponent = 2147483647 Result = -INF229..... Exponent = -2147483648 Result = 0...

Full Screen

Full Screen

params_test.go

Source:params_test.go Github

copy

Full Screen

1// Copyright 2018 Frédéric Guillot. All rights reserved.2// Use of this source code is governed by the Apache 2.03// license that can be found in the LICENSE file.4package request // import "miniflux.app/http/request"5import (6 "net/http"7 "net/http/httptest"8 "net/url"9 "testing"10 "github.com/gorilla/mux"11)12func TestFormInt64Value(t *testing.T) {13 f := url.Values{}14 f.Set("integer value", "42")15 f.Set("invalid value", "invalid integer")16 r := &http.Request{Form: f}17 result := FormInt64Value(r, "integer value")18 expected := int64(42)19 if result != expected {20 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)21 }22 result = FormInt64Value(r, "invalid value")23 expected = int64(0)24 if result != expected {25 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)26 }27 result = FormInt64Value(r, "missing value")28 expected = int64(0)29 if result != expected {30 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)31 }32}33func TestRouteStringParam(t *testing.T) {34 router := mux.NewRouter()35 router.HandleFunc("/route/{variable}/index", func(w http.ResponseWriter, r *http.Request) {36 result := RouteStringParam(r, "variable")37 expected := "value"38 if result != expected {39 t.Errorf(`Unexpected result, got %q instead of %q`, result, expected)40 }41 result = RouteStringParam(r, "missing variable")42 expected = ""43 if result != expected {44 t.Errorf(`Unexpected result, got %q instead of %q`, result, expected)45 }46 })47 r, err := http.NewRequest("GET", "/route/value/index", nil)48 if err != nil {49 t.Fatal(err)50 }51 w := httptest.NewRecorder()52 router.ServeHTTP(w, r)53}54func TestRouteInt64Param(t *testing.T) {55 router := mux.NewRouter()56 router.HandleFunc("/a/{variable1}/b/{variable2}/c/{variable3}", func(w http.ResponseWriter, r *http.Request) {57 result := RouteInt64Param(r, "variable1")58 expected := int64(42)59 if result != expected {60 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)61 }62 result = RouteInt64Param(r, "missing variable")63 expected = 064 if result != expected {65 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)66 }67 result = RouteInt64Param(r, "variable2")68 expected = 069 if result != expected {70 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)71 }72 result = RouteInt64Param(r, "variable3")73 expected = 074 if result != expected {75 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)76 }77 })78 r, err := http.NewRequest("GET", "/a/42/b/not-int/c/-10", nil)79 if err != nil {80 t.Fatal(err)81 }82 w := httptest.NewRecorder()83 router.ServeHTTP(w, r)84}85func TestQueryStringParam(t *testing.T) {86 u, _ := url.Parse("http://example.org/?key=value")87 r := &http.Request{URL: u}88 result := QueryStringParam(r, "key", "fallback")89 expected := "value"90 if result != expected {91 t.Errorf(`Unexpected result, got %q instead of %q`, result, expected)92 }93 result = QueryStringParam(r, "missing key", "fallback")94 expected = "fallback"95 if result != expected {96 t.Errorf(`Unexpected result, got %q instead of %q`, result, expected)97 }98}99func TestQueryIntParam(t *testing.T) {100 u, _ := url.Parse("http://example.org/?key=42&invalid=value&negative=-5")101 r := &http.Request{URL: u}102 result := QueryIntParam(r, "key", 84)103 expected := 42104 if result != expected {105 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)106 }107 result = QueryIntParam(r, "missing key", 84)108 expected = 84109 if result != expected {110 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)111 }112 result = QueryIntParam(r, "negative", 69)113 expected = 69114 if result != expected {115 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)116 }117 result = QueryIntParam(r, "invalid", 99)118 expected = 99119 if result != expected {120 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)121 }122}123func TestQueryInt64Param(t *testing.T) {124 u, _ := url.Parse("http://example.org/?key=42&invalid=value&negative=-5")125 r := &http.Request{URL: u}126 result := QueryInt64Param(r, "key", int64(84))127 expected := int64(42)128 if result != expected {129 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)130 }131 result = QueryInt64Param(r, "missing key", int64(84))132 expected = int64(84)133 if result != expected {134 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)135 }136 result = QueryInt64Param(r, "invalid", int64(69))137 expected = int64(69)138 if result != expected {139 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)140 }141 result = QueryInt64Param(r, "invalid", int64(99))142 expected = int64(99)143 if result != expected {144 t.Errorf(`Unexpected result, got %d instead of %d`, result, expected)145 }146}147func TestHasQueryParam(t *testing.T) {148 u, _ := url.Parse("http://example.org/?key=42")149 r := &http.Request{URL: u}150 result := HasQueryParam(r, "key")151 expected := true152 if result != expected {153 t.Errorf(`Unexpected result, got %v instead of %v`, result, expected)154 }155 result = HasQueryParam(r, "missing key")156 expected = false157 if result != expected {158 t.Errorf(`Unexpected result, got %v instead of %v`, result, expected)159 }160}...

Full Screen

Full Screen

field_test.go

Source:field_test.go Github

copy

Full Screen

1package helper2import (3 "testing"4)5func TestParseFields_Wildcard(t *testing.T) {6 fields := "*"7 result := ParseFields(fields)8 if _, ok := result["*"]; !ok {9 t.Fatalf("result[*] should exist: %#v", result)10 }11 if result["*"] != nil {12 t.Fatalf("result[*] should be nil: %#v", result)13 }14}15func TestParseFields_Flat(t *testing.T) {16 fields := "profile"17 result := ParseFields(fields)18 if _, ok := result["profile"]; !ok {19 t.Fatalf("result[profile] should exist: %#v", result)20 }21 if result["profile"] != nil {22 t.Fatalf("result[profile] should be nil: %#v", result)23 }24}25func TestParseFields_Nested(t *testing.T) {26 fields := "profile.nation"27 result := ParseFields(fields)28 if _, ok := result["profile"]; !ok {29 t.Fatalf("result[profile] should exist: %#v", result)30 }31 if _, ok := result["profile"].(map[string]interface{}); !ok {32 t.Fatalf("result[profile] should be map: %#v", result)33 }34 if _, ok := result["profile"].(map[string]interface{})["nation"]; !ok {35 t.Fatalf("result[profile][nation] should exist: %#v", result)36 }37 if result["profile"].(map[string]interface{})["nation"] != nil {38 t.Fatalf("result[profile][nation] should be nil: %#v", result)39 }40}41func TestParseFields_NestedDeeply(t *testing.T) {42 fields := "profile.nation.name"43 result := ParseFields(fields)44 if _, ok := result["profile"]; !ok {45 t.Fatalf("result[profile] should exist: %#v", result)46 }47 if _, ok := result["profile"].(map[string]interface{}); !ok {48 t.Fatalf("result[profile] should be map: %#v", result)49 }50 if _, ok := result["profile"].(map[string]interface{})["nation"]; !ok {51 t.Fatalf("result[profile][nation] should exist: %#v", result)52 }53 if _, ok := result["profile"].(map[string]interface{})["nation"].(map[string]interface{}); !ok {54 t.Fatalf("result[profile][nation] should be map: %#v", result)55 }56 if _, ok := result["profile"].(map[string]interface{})["nation"].(map[string]interface{})["name"]; !ok {57 t.Fatalf("result[profile][nation][name] should exist: %#v", result)58 }59 if result["profile"].(map[string]interface{})["nation"].(map[string]interface{})["name"] != nil {60 t.Fatalf("result[profile][nation][name] should be nil: %#v", result)61 }62}63func TestParseFields_MultipleFields(t *testing.T) {64 fields := "profile.nation.name,emails"65 result := ParseFields(fields)66 if _, ok := result["profile"]; !ok {67 t.Fatalf("result[profile] should exist: %#v", result)68 }69 if _, ok := result["profile"].(map[string]interface{}); !ok {70 t.Fatalf("result[profile] should be map: %#v", result)71 }72 if _, ok := result["profile"].(map[string]interface{})["nation"]; !ok {73 t.Fatalf("result[profile][nation] should exist: %#v", result)74 }75 if _, ok := result["profile"].(map[string]interface{})["nation"].(map[string]interface{}); !ok {76 t.Fatalf("result[profile][nation] should be map: %#v", result)77 }78 if _, ok := result["profile"].(map[string]interface{})["nation"].(map[string]interface{})["name"]; !ok {79 t.Fatalf("result[profile][nation][name] should exist: %#v", result)80 }81 if result["profile"].(map[string]interface{})["nation"].(map[string]interface{})["name"] != nil {82 t.Fatalf("result[profile][nation][name] should be nil: %#v", result)83 }84 if _, ok := result["emails"]; !ok {85 t.Fatalf("result[emails] should exist: %#v", result)86 }87 if result["emails"] != nil {88 t.Fatalf("result[emails] should be map: %#v", result)89 }90}91func TestParseFields_Included(t *testing.T) {92 fields := "profile.nation.name,profile"93 result := ParseFields(fields)94 if _, ok := result["profile"]; !ok {95 t.Fatalf("result[profile] should exist: %#v", result)96 }97 if result["profile"] != nil {98 t.Fatalf("result[profile] should be nil: %#v", result)99 }100}...

Full Screen

Full Screen

Result

Using AI Code Generation

copy

Full Screen

1import Mockingbird2let result = Result<String, Error>.success("Success")3switch result {4case .success(let value):5 print(value)6case .failure(let error):7 print(error)8}9import Foundation10let result = Result<String, Error>.success("Success")11switch result {12case .success(let value):13 print(value)14case .failure(let error):15 print(error)16}17Mockingbird: How to use mock() function18Mockingbird: How to use mock() function with closure19Mockingbird: How to use mock() function with closure and return value20Mockingbird: How to use mock() function with closure, return value and parameters21Mockingbird: How to use mock() function with closure, return value, parameters and generic type22Mockingbird: How to use mock() function with closure, return value, parameters, generic type and protocol23Mockingbird: How to use mock() function with closure, return value, parameters, generic type, protocol and class24Mockingbird: How to use mock() function with closure, return value, parameters, generic type, protocol, class and struct25Mockingbird: How to use mock() function with closure, return value, parameters, generic type, protocol, class, struct and enum26Mockingbird: How to use mock() function with closure, return value, parameters, generic type, protocol, class, struct, enum and associated type27Mockingbird: How to use mock() function with closure, return value, parameters, generic type, protocol, class, struct, enum, associated type and where clause28Mockingbird: How to use mock() function with closure,

Full Screen

Full Screen

Result

Using AI Code Generation

copy

Full Screen

1import Mockingbird2let result = Result<Int, Error>.success(0)3import Result4let result = Result<Int, Error>.success(0)5@testable import Mockingbird6let result = Result<Int, Error>.success(0)7@testable import Result8let result = Result<Int, Error>.success(0)9import Mockingbird10import Result11let result = Result<Int, Error>.success(0)12import Mockingbird13import Result14let result = Result<Int, Error>.success(0)15import Mockingbird16import Result17let result = Result<Int, Error>.success(0)18import Mockingbird19import Result20let result = Result<Int, Error>.success(0)21import Mockingbird22import Result23let result = Result<Int, Error>.success(0)24import Mockingbird25import Result26let result = Result<Int, Error>.success(0)27import Mockingbird28import Result29let result = Result<Int, Error>.success(0)30import Mock

Full Screen

Full Screen

Result

Using AI Code Generation

copy

Full Screen

1let result = Result<Bool, Error>.success(true)2let result = Result<Bool, Error>.failure(NSError())3let result = Result<Bool, Error>.failure(NSError(domain: "com.domain", code: 1, userInfo: nil))4let result = Result<Bool, Error>.success(true)5let result = Result<Bool, Error>.failure(NSError())6let result = Result<Bool, Error>.failure(NSError(domain: "com.domain", code: 1, userInfo: nil))7let result = Result<Bool, Error>.success(true)8let result = Result<Bool, Error>.failure(NSError())9let result = Result<Bool, Error>.failure(NSError(domain: "com.domain", code: 1, userInfo: nil))10let result = Result<Bool, Error>.success(true)11let result = Result<Bool, Error>.failure(NSError())12let result = Result<Bool, Error>.failure(NSError(domain: "com.domain", code: 1, userInfo: nil))13let result = Result<Bool, Error>.success(true)14let result = Result<Bool, Error>.failure(NSError())15let result = Result<Bool, Error>.failure(NSError(domain: "com.domain", code: 1, userInfo: nil))16let result = Result<Bool, Error>.success(true)17let result = Result<Bool, Error>.failure(NSError())18let result = Result<Bool, Error>.failure(NSError(domain: "com.domain", code: 1, userInfo: nil))19let result = Result<Bool, Error>.success(true)20let result = Result<Bool, Error>.failure(NSError())21let result = Result<Bool, Error>.failure(NSError(domain: "com.domain", code: 1, userInfo: nil))22let result = Result<Bool, Error>.success(true)

Full Screen

Full Screen

Result

Using AI Code Generation

copy

Full Screen

1import XCTest2import Mockingbird3@testable import MockingbirdTestsHost4class Test: XCTestCase {5 override func setUp() {6 mock = mock(MockingbirdTestsHost.MockProtocol.self)7 mock2 = mock(MockingbirdTestsHost.MockProtocol.self)8 }9 func test1() {10 given(mock.someFunction()) ~> "test"11 given(mock2.someFunction()) ~> "test2"12 XCTAssertEqual(try? mock.someFunction(), "test")13 XCTAssertEqual(try? mock2.someFunction(), "test2")14 }15 func test2() {16 given(mock.someFunction()) ~> "test"17 given(mock2.someFunction()) ~> "test2"18 XCTAssertEqual(try? mock.someFunction(), "test")19 XCTAssertEqual(try? mock2.someFunction(), "test2")20 }21}22import XCTest23import Mockingbird24@testable import MockingbirdTestsHost25class Test: XCTestCase {26 override func setUp() {27 mock = mock(MockingbirdTestsHost.MockProtocol.self)28 mock2 = mock(MockingbirdTestsHost.MockProtocol.self)29 }30 func test1() {31 given(mock.someFunction()) ~> "test"32 given(mock2.someFunction()) ~> "test2"33 XCTAssertEqual(try? mock.someFunction(), "test")34 XCTAssertEqual(try? mock2.someFunction(), "test2")35 }36 func test2() {37 given(mock.someFunction()) ~> "test"38 given(mock2.someFunction()) ~> "test2"39 XCTAssertEqual(try? mock.someFunction(), "test")40 XCTAssertEqual(try? mock2.someFunction(), "test2")41 }42}43import XCTest44import Mockingbird45@testable import MockingbirdTestsHost46class Test: XCTestCase {47 override func setUp() {48 mock = mock(MockingbirdTestsHost.MockProtocol.self)

Full Screen

Full Screen

Result

Using AI Code Generation

copy

Full Screen

1import Foundation2import Mockingbird3import MockingbirdFramework4class Test1 {5 func test() {6 let result = Result<String, MockingbirdError>.success("Success")7 print(result)8 }9}10import Foundation11import Mockingbird12import MockingbirdFramework13class Test2 {14 func test() {15 let result = Result<String, Error>.success("Success")16 print(result)17 }18}19import Foundation20import Mockingbird21import MockingbirdFramework22class Test3 {23 func test() {24 let result = Result<String, Error>.success("Success")25 print(result)26 }27}28import Foundation29import Mockingbird30import MockingbirdFramework31class Test4 {32 func test() {33 let result = Result<String, Error>.success("Success")34 print(result)35 }36}37import Foundation38import Mockingbird39import MockingbirdFramework40class Test5 {41 func test() {42 let result = Result<String, Error>.success("Success")43 print(result)44 }45}46import Foundation47import Mockingbird48import MockingbirdFramework49class Test6 {50 func test() {51 let result = Result<String, Error>.success("Success")52 print(result)53 }54}55import Foundation56import Mockingbird57import MockingbirdFramework58class Test7 {59 func test() {60 let result = Result<String, Error>.success("Success")61 print(result)62 }63}64import Foundation65import Mockingbird66import MockingbirdFramework67class Test8 {68 func test() {69 let result = Result<String, Error>.success("Success")70 print(result)71 }72}73import Foundation74import Mockingbird75import MockingbirdFramework76class Test9 {77 func test() {

Full Screen

Full Screen

Result

Using AI Code Generation

copy

Full Screen

1import Mockingbird2let result = Result<Int, NSError>.success(42)3let result2 = Result<Int, NSError>.success(42)4let result3 = Result<Int, NSError>.failure(NSError(domain: "test", code: 0, userInfo: nil))5let result4 = Result<Int, NSError>.failure(NSError(domain: "test", code: 0, userInfo: nil))6import Foundation7let result = Result<Int, NSError>.success(42)8let result2 = Result<Int, NSError>.success(42)9let result3 = Result<Int, NSError>.failure(NSError(domain: "test", code: 0, userInfo: nil))10let result4 = Result<Int, NSError>.failure(NSError(domain: "test", code: 0, userInfo: nil))

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Mockingbird automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful