1
0
Fork 0
gobject-generator/regression/tier4/GdkSmoke.swift

39 lines
1.6 KiB
Swift

// GdkSmoke.swift
// Tier-4-only runtime smoke test for Gdk (Phase E3). Proves against the
// REAL libgtk-4, linked at runtime that:
// 1. `keyvalFromName(keyvalName:)` reaches the real `gdk_keyval_from_name`
// C call, marshalling a Swift `String` through `withCString` and the
// returned `guint` keyval back as `UInt32`.
// 2. `keyvalName(keyval:)` reaches the real `gdk_keyval_name`, marshalling
// the `guint` argument and the returned `const gchar*` back into a
// Swift `String?` a round trip through both keyval accessors.
//
// Both are display-free: no `GdkDisplay`/surface is created, so this runs
// without a windowing backend.
//
// Not generated. `scripts/smoke-test.sh <tier>` copies tier 1 and the selected
// tier's fixtures for tiers 2 through 5. Tier 6/all copies every tier's fixtures
// into one full-stack SmokeTests target. Only installed for tier >= 4.
import Testing
import GLib
import GObject
import Gdk
@Suite("Tier 4 Gdk smoke tests")
struct GdkSmokeTests {
@Test("keyvalFromName(keyvalName:) reaches the real gdk_keyval_from_name and reports the known GDK_KEY_a value")
func keyvalFromNameReturnsKnownKeyval() throws {
let keyval = keyvalFromName(keyvalName: "a")
// GDK_KEY_a is a fixed constant (0x61, matching ASCII 'a').
#expect(keyval == 0x61)
}
@Test("keyvalName(keyval:) round-trips the value keyvalFromName reports back to the original name")
func keyvalRoundTrips() throws {
let keyval = keyvalFromName(keyvalName: "a")
let name = keyvalName(keyval: keyval)
#expect(name == "a")
}
}