test_that("BAM with one read can be properly interpreted", {

    ## recall - whole ref is A otherwise
    chr <- 10
    pos <- cbind(
        CHR = rep(chr, 7),
        POS = c(9, 11, 13, 15, 17, 19, 21),
        REF = c("G", "G", "G", "G", "G", "G", "G"),
        ALT = c("C", "C", "C", "C", "C", "C", "C")
    )
    ## https://github.com/samtools/hts-specs/blob/master/SAMv1.pdf

    bam_file <- make_simple_bam(
        file_stem = file.path(tempdir(), "simple"),
        sam = make_simple_sam_text(
            list(
                c("r001", "0", chr, "17", "60",
                  "6M", "*", "0", "0",
                  "GACCGA", ":;<=>?")
            ),
            chr
        )
    )

    ## 1: 0-based number of SNPs
    ## 2: 0-based central SNP
    ## 3: bq, - = ref, + = alt
    ## 4: 0-based position in pos
    expected_sample_reads <- list(
        list(
            2, 5,
            matrix(c(-25, 27, -29), ncol = 1),
            matrix(c(4, 5, 6), ncol = 1)
        )
    )


    regionName <- "region-name"
    loadBamAndConvert(
        iBam = 1,
        L = as.integer(pos[, 2]),
        pos = pos,
        nSNPs = as.integer(nrow(pos)),
        bam_files = bam_file,
        N = 1,
        sampleNames = "test-name-one-read",
        inputdir = tempdir(),
        regionName = regionName,
        tempdir = tempdir(),
        chr = chr,
        chrStart = 1,
        chrEnd = 100
    )

    load(file_sampleReads(tempdir(), 1, regionName))

    expect_equal(
        sampleReads,
        expected_sample_reads
    )

})


## test_that("can do pseudoHaploid updates in C++", {

##     for(n in c(1e2, 1e3, 1e4)) {
##     rcpp_test(option = 0, n = n)
##     rcpp_test(option = 1, n = n)
##     }
    
## })
