package com.foxx.androidcast.ota;

/*********************************************************************
 * OtaVersionTest.java
 * Created at: Wed 20 May 2026 14:31:55 +0200
 * Updated at: Wed 20 May 2026 15:17:13 +0200 by Anton Afanasyeu <a.afanasieff@gmail.com>
 * Commit: 5d8e82d2e60a21fff3138d2a394ee4e8b4c6dcb8
 * class OtaVersionTest
 * Contributors:
 *    - Anton Afanasyeu <a.afanasieff@gmail.com> (2 commits, 33 lines)
 *    - Cursor Agent (project assistant)
 * Digest: SHA256	85d87330e73f19e38997627ff76ec7af84d0c18f0c3ed67a9833efb1e69b3290
**********************************************************************/
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class OtaVersionTest {
    @Test
    public void pack_unpack_roundTrip() {
        assertEquals(105, OtaVersion.pack(0, 1, 5));
        OtaVersion v = OtaVersion.fromPacked(105);
        assertEquals(0, v.major);
        assertEquals(1, v.minor);
        assertEquals(5, v.build);
        assertEquals("0.1.5", v.displayName());
    }

    @Test
    public void isUpdateAvailable_comparesPacked() {
        assertTrue(OtaVersion.isUpdateAvailable(105, 100));
        assertFalse(OtaVersion.isUpdateAvailable(100, 105));
        assertFalse(OtaVersion.isUpdateAvailable(100, 100));
    }
}
