if (1 == 0) {
    
    library("testthat"); library("STITCH"); library("rrbgen")
    dir <- "~/proj/STITCH/"
    setwd(paste0(dir, "/STITCH/R"))
    a <- dir(pattern = "*.R")
    b <- grep("~", a)
    if (length(b) > 0) {
        a <- a[-b]
    }
    o <- sapply(a, source)
    setwd(dir)
    Sys.setenv(PATH = paste0(getwd(), ":", Sys.getenv("PATH")))

}

test_that("binary/integer storage format for reference haps makes sense", {

    set.seed(91)
    K <- 10
    
    ## try it just at, under, and over 32
    for(nSNPs in c(90, 95, 96, 97)) {

        ## 
        nbSNPs <- ceiling(nSNPs / 32)

        ## make some test data
        rhi_t <- array(as.integer(round(runif(K * nSNPs))), c(K, nSNPs))
        rhb_t <- make_rhb_t_from_rhi_t(rhi_t)

        ## check can expand / contract and get the same answer
        for(k in 1:K) {
            expect_equal(rhi_t[k, ], int_expand(int_contract(rhi_t[k, ]), nSNPs))
            expect_equal(rhi_t[k, ], rcpp_int_expand(int_contract(rhi_t[k, ]), nSNPs))
            expect_equal(int_contract(rhi_t[k, ]), rcpp_int_contract(rhi_t[k, ]))
        }

        ## specifically test edge cases
        for(i in 1:2) {
            hap <- integer(nSNPs)
            hap[] <- 0L
            if (i == 1) { hap[1] <- 1L}
            if (i == 2) { hap[length(hap)] <- 1L}
            if (i == 3) { hap[] <- 1L}
            expect_equal(int_contract(hap), rcpp_int_contract(hap))
            expect_equal(hap, int_expand(int_contract(hap), nSNPs))
            expect_equal(hap, rcpp_int_expand(int_contract(hap), nSNPs))
        }


    }
    
})
