File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ // RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
2+ //
3+ // REQUIRES: executable_test
4+ //
5+ // Enable this everywhere once we have a solution for modularizing libstdc++: rdar://87654514
6+ // REQUIRES: OS=macosx
7+
8+ import StdlibUnittest
9+ import StdVector
10+ import std. vector
11+
12+ var StdIteratorTestSuite = TestSuite ( " StdIterator " )
13+
14+ StdIteratorTestSuite . test ( " init " ) {
15+ var vector = Vector ( )
16+ var _1 : CInt = 1
17+ //There seems to be an issue when importing this method, where the const_ref is mapped with
18+ //the correct typealias to be able to pass immutable values. related to: https://github.com/apple/swift/pull/41611
19+ vector. push_back ( & _1)
20+ //ideally we should call vector.begin(), however we need to prevent a copy of self before vector.begin() is invoked
21+ //current workaround is to use beginMutating()
22+ let it = vector. beginMutating ( )
23+ expectEqual ( it [ 0 ] , 1 )
24+ }
25+
26+ StdIteratorTestSuite . test ( " advance " ) {
27+ var vector = Vector ( )
28+ var _1 : CInt = 1 , _2 : CInt = 2 , _3 : CInt = 3
29+ vector. push_back ( & _1)
30+ vector. push_back ( & _2)
31+ vector. push_back ( & _3)
32+ var it = vector. beginMutating ( )
33+ std. __1. advance ( & it, 2 )
34+ expectEqual ( it [ 0 ] , 3 )
35+ }
36+
37+ runAllTests ( )
You can’t perform that action at this time.
0 commit comments