|
| 1 | +import Foundation |
| 2 | + |
| 3 | +@_cdecl("main") |
| 4 | +func main() -> Int { |
| 5 | +// targetTag can be nil, version or latest. When latestAvailable is false, targetTag can't be latest. |
| 6 | +// So it's a combination of 2*2*5 = 20 cases. |
| 7 | + |
| 8 | +// Release to Release |
| 9 | + // latest >> stable = current |
| 10 | + assert(getTag(currentDebug: false, targetDebug: false, latestAvailable: false, targetTag: nil) == nil) |
| 11 | + // latest >> stable > current |
| 12 | + assert(getTag(currentDebug: false, targetDebug: false, latestAvailable: false, targetTag: "1") == "1") |
| 13 | + // latest = current |
| 14 | + assert(getTag(currentDebug: false, targetDebug: false, latestAvailable: true, targetTag: nil) == nil) |
| 15 | + // stable > current |
| 16 | + assert(getTag(currentDebug: false, targetDebug: false, latestAvailable: true, targetTag: "1") == "1") |
| 17 | + // latest > current >= stable |
| 18 | + assert(getTag(currentDebug: false, targetDebug: false, latestAvailable: true, targetTag: "latest") == "latest") |
| 19 | + |
| 20 | +// Release to Debug |
| 21 | + // latest >> stable = current |
| 22 | + let _ = getTag(currentDebug: false, targetDebug: true, latestAvailable: false, targetTag: nil) // Switch button not clickable. |
| 23 | + // latest >> stable > current |
| 24 | + let _ = getTag(currentDebug: false, targetDebug: true, latestAvailable: false, targetTag: "1") // Switch button not clickable. |
| 25 | + // latest = current |
| 26 | + assert(getTag(currentDebug: false, targetDebug: true, latestAvailable: true, targetTag: nil) == "latest") |
| 27 | + // stable > current |
| 28 | + assert(getTag(currentDebug: false, targetDebug: true, latestAvailable: true, targetTag: "1") == "latest") |
| 29 | + // latest > current >= stable |
| 30 | + assert(getTag(currentDebug: false, targetDebug: true, latestAvailable: true, targetTag: "latest") == "latest") |
| 31 | + |
| 32 | +// Debug to Release |
| 33 | + // latest >> stable = current |
| 34 | + let _ = getTag(currentDebug: true, targetDebug: false, latestAvailable: false, targetTag: nil) // We don't provide debug stable. |
| 35 | + // latest >> stable > current |
| 36 | + assert(getTag(currentDebug: true, targetDebug: false, latestAvailable: false, targetTag: "1") == "1") |
| 37 | + // latest = current |
| 38 | + assert(getTag(currentDebug: true, targetDebug: false, latestAvailable: true, targetTag: nil) == "latest") |
| 39 | + // stable > current |
| 40 | + assert(getTag(currentDebug: true, targetDebug: false, latestAvailable: true, targetTag: "1") == "1") |
| 41 | + // latest > current >= stable |
| 42 | + assert(getTag(currentDebug: true, targetDebug: false, latestAvailable: true, targetTag: "latest") == "latest") |
| 43 | + |
| 44 | +// Debug to Debug |
| 45 | + // latest >> stable = current |
| 46 | + let _ = getTag(currentDebug: true, targetDebug: true, latestAvailable: false, targetTag: nil) // We don't provide debug stable. |
| 47 | + // latest >> stable > current |
| 48 | + let _ = getTag(currentDebug: true, targetDebug: true, latestAvailable: false, targetTag: "1") // Update button not clickable. |
| 49 | + // latest = current |
| 50 | + let _ = getTag(currentDebug: true, targetDebug: true, latestAvailable: true, targetTag: nil) // Update button not clickable. |
| 51 | + // stable > current |
| 52 | + assert(getTag(currentDebug: true, targetDebug: true, latestAvailable: true, targetTag: "1") == "latest") |
| 53 | + // latest > current >= stable |
| 54 | + assert(getTag(currentDebug: true, targetDebug: true, latestAvailable: true, targetTag: "latest") == "latest") |
| 55 | + |
| 56 | + return 0 |
| 57 | +} |
0 commit comments