/ tests / SecLegacyCodeRegressions / legacyCodeRegressions.mm
legacyCodeRegressions.mm
 1  // DANGER Objective C++
 2  
 3  
 4  #import <XCTest/XCTest.h>
 5  #include <security_utilities/threading.h>
 6  
 7  struct ThreadTestClass : public Thread {
 8      XCTestExpectation *expectation;
 9      
10      ThreadTestClass(XCTestExpectation *e): Thread("test"), expectation(e) {  }
11      void threadAction() {
12          [expectation fulfill];
13      }
14  };
15  
16  @interface legacyCodeRegressions : XCTestCase
17  @end
18  
19  @implementation legacyCodeRegressions
20  
21  - (void)testThread {
22      XCTestExpectation *e = [self expectationWithDescription:@"wait"];
23      
24      auto t = new ThreadTestClass(e);
25      t->threadRun();
26      [self waitForExpectations:@[e] timeout:10.0];
27      delete t;
28  }
29  
30  @end