Skip to content

Commit

Permalink
Bits and ends.
Browse files Browse the repository at this point in the history
  • Loading branch information
kondziu committed Jun 22, 2020
1 parent 056daa4 commit c406051
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ufovectors/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Maintainer: Konrad Siek <[email protected]>
License: GPL-2 | GPL-3
Encoding: UTF-8
LazyData: true
Depends: ufos
LinkingTo: ufos
Depends: ufos, viewports
LinkingTo: ufos, viewports
NeedsCompilation: yes
Suggests:
knitr,
Expand Down
6 changes: 5 additions & 1 deletion ufovectors/src/ufo_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include <stdbool.h>
#include <stdint.h>

#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>

#include "../include/ufos.h"
#include "helpers.h"
#include "debug.h"
Expand Down Expand Up @@ -317,4 +321,4 @@ SEXP ufo_csv(SEXP/*STRSXP*/ path_sexp, SEXP/*INTSXP*/ min_load_count_sexp, SEXP/

UNPROTECT(1 + csv_metadata->columns + 2);
return data_frame;
}
}
6 changes: 5 additions & 1 deletion ufovectors/src/ufo_vectors.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#include <stdlib.h>
#include <assert.h>

#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>

#include "../include/ufos.h"
#include "ufo_vectors.h"
#include "ufo_metadata.h"
Expand Down Expand Up @@ -155,4 +159,4 @@ SEXP ufo_matrix_lglsxp_bin(SEXP/*STRSXP*/ path, SEXP/*INTSXP*/ rows, SEXP/*INTSX

SEXP ufo_matrix_rawsxp_bin(SEXP/*STRSXP*/ path, SEXP/*INTSXP*/ rows, SEXP/*INTSXP*/ cols, SEXP/*INTSXP*/ min_load_count) {
return __make_matrix(UFO_RAW, path, rows, cols, min_load_count);
}
}
4 changes: 4 additions & 0 deletions ufovectors/tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(ufovectors)

test_check("ufovectors")
18 changes: 18 additions & 0 deletions ufovectors/tests/testthat/test-file-backed-add-1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
context("Vector operations on file-backed integer vectors")

dir <- "../../data"

test_that("sum 1K ones", {
path <- paste(dir, "1K_ones_int.bin", sep="/")
expect_equal(sum(ufo_integer_bin(path) + 1), 2 * 1000)
})

test_that("sum 1M ones", {
path <- paste(dir, "1M_ones_int.bin", sep="/")
expect_equal(sum(ufo_integer_bin(path) + 1), 2 * 1000000)
})

test_that("sum 1G ones", {
path <- paste(dir, "1G_ones_int.bin", sep="/")
expect_equal(sum(ufo_integer_bin(path) + 1), 2 * 1000000000)
})
18 changes: 18 additions & 0 deletions ufovectors/tests/testthat/test-file-backed-sum.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
context("Sum on file-backed integer vectors")

dir <- "../../data"

test_that("sum 1K ones", {
path <- paste(dir, "1K_ones_int.bin", sep="/")
expect_equal(sum(ufo_integer_bin(path)), 1000)
})

test_that("sum 1M ones", {
path <- paste(dir, "1M_ones_int.bin", sep="/")
expect_equal(sum(ufo_integer_bin(path)), 1000000)
})

test_that("sum 1G ones", {
path <- paste(dir, "1G_ones_int.bin", sep="/")
expect_equal(sum(ufo_integer_bin(path)), 1000000000)
})

0 comments on commit c406051

Please sign in to comment.