Module: Pacct::Test
- Defined in:
- ext/pacct/pacct_c.c,
ext/pacct/pacct_c.c
Overview
Contains unit-testing methods
Only defined when RSpec is loaded
Class Method Summary collapse
-
.check_call(test) ⇒ Object
Unit testing code.
- .comp_t_to_ulong(val) ⇒ Object
- .read_failure ⇒ Object
- .write_failure ⇒ Object
Class Method Details
.check_call(test) ⇒ Object
Unit testing code
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 |
# File 'ext/pacct/pacct_c.c', line 710 static VALUE test_check_call_macro(VALUE self, VALUE test) { int i = NUM2INT(test); switch(i) { case 0: CHECK_CALL(0, 0); break; case 1: CHECK_CALL(1, 0); break; case 2: CHECK_CALL(errno = 0, 1); case 3: CHECK_CALL(errno = ERANGE, 0); default: rb_raise(rb_eRangeError, "Unknown test code %i", i); } return Qnil; } |
.comp_t_to_ulong(val) ⇒ Object
764 765 766 767 768 |
# File 'ext/pacct/pacct_c.c', line 764 static VALUE test_comp_t_to_ulong(VALUE self, VALUE val) { comp_t c = (comp_t)NUM2UINT(val); unsigned long result = comp_t_to_ulong(c); return ULONG2NUM(result); } |
.read_failure ⇒ Object
729 730 731 732 733 734 735 736 737 738 739 740 741 |
# File 'ext/pacct/pacct_c.c', line 729 static VALUE test_read_failure(VALUE self) { PacctLog log; //VALUE entry = pacct_entry_new(NULL); const char* filename = "/dev/null"; log.num_entries = 0; log.filename = malloc(strlen(filename) + 1); ENSURE_ALLOCATED(log.filename); strcpy(log.filename, filename); log.file = fopen(log.filename, "r"); pacct_entry_new(&log); return Qnil; } |
.write_failure ⇒ Object
743 744 745 746 747 748 749 750 751 752 753 754 755 756 |
# File 'ext/pacct/pacct_c.c', line 743 static VALUE test_write_failure(VALUE self) { PacctLog* ptr; VALUE log = Data_Make_Struct(cLog, PacctLog, 0, pacct_log_free, ptr); VALUE entry = pacct_entry_new(NULL); const char* filename = "spec/pacct_spec.rb"; ptr->num_entries = 0; ptr->filename = malloc(strlen(filename) + 1); ENSURE_ALLOCATED(ptr->filename); strcpy(ptr->filename, filename); ptr->file = fopen(ptr->filename, "r"); write_entry(log, entry); return Qnil; } |