Skip to content

Commit

Permalink
refs #107
Browse files Browse the repository at this point in the history
  • Loading branch information
Herbert Koelman committed Dec 2, 2016
1 parent 9b78efb commit c644027
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 8 deletions.
9 changes: 1 addition & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,4 @@ access*
*.err

# sample programs
ulog_test
exceptions_tests
buffer_test
multi_context_test
queue_test
transaction_test
sample_fml_table.h

*test
121 changes: 121 additions & 0 deletions tests/clients/field_test.bcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/* $Id$

Sample Tuxedo client using ATMI++ libray.

*/
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <string>
#include <iostream>
#include <fstream>
#include <typeinfo>
#include "atmi/atmi++.hpp"

#include "sample_fml_table.h"

template< class T, FLDID32 F = 0 >
class _field: public atmi::Tfield<T> {
public:
_field(): atmi::Tfield<T>(F){
}

_field( FLDID32 id ): atmi::Tfield<T>(id){
}

T operator=( T v ){
atmi::Tfield<T>::value = v;

return atmi::Tfield<T>::value ;
}
};

typedef _field<std::string,EMPNAME> prenom_t;
typedef _field<long,EMPID> empid_t;
typedef _field<std::string> void_t;

class fields {
public:
fields(){
prenom = "hello world" ;
std::cout << __FUNCTION__ << ": " << prenom << std::endl ;
}

private:
prenom_t prenom ;
};


class field_empid: public atmi::Tfield<long> {
public:
field_empid(): atmi::Tfield<long>(EMPID){
}

};

// program main -------------------------------------------------

int main ( int argc, char **argv ) {

auto status = EXIT_FAILURE;
try {

std::cout << "field sample program (" << atmi::cpp_atmi_version() <<")." << std::endl;

std::cout << std::endl << "---------------------------" << std::endl << std::endl;

{
std::cout << "TEST >>>> IMPID field ID: " << std::endl;

atmi::Tfield<long> empid_(EMPID);
std::auto_ptr<atmi::field> empid_ptr(new atmi::Tfield<long, EMPID>);
std::cout << empid_ptr->name() << "(PTR): " << empid_ptr->what() << std::endl;

atmi::Tfield<long, EMPID> empid;
empid = 10;
std::cout << empid.name() << ": " << empid << std::endl << " " << empid.what() << std::endl;

std::cout << "TEST >>>> succesful" << std::endl ;
}

{
std::cout << "TEST >>>> IMPID field name: " << std::endl;

atmi::Tfield<long> empid("EMPID");
empid = 10;
std::cout << empid.name() << ": " << empid << std::endl << " " << empid.what() << std::endl;

std::cout << "TEST >>>> succesful" << std::endl ;
}

std::cout << std::endl << "---------------------------" << std::endl << std::endl;

{
std::cout << "TEST >>>> Tfields type mismatch detection: " << std::endl;

try {
atmi::Tfield<short> empid(EMPID);
}catch ( std::exception &err ){
std::cerr << "field test failed. " << err.what() << std::endl;
}

try {
atmi::Tfield<short> empid("EMPID");
}catch ( std::exception &err ){
std::cerr << "field test failed. " << err.what() << std::endl;
}

std::cout << "TEST >>>> succesful" << std::endl ;
}

std::cout << std::endl << "---------------------------" << std::endl << std::endl;

std::cout << "END of field sample program" << std::endl ;
status = EXIT_SUCCESS;

} catch ( std::exception &err ) {
std::cerr << "field test failed. " << err.what() << std::endl;
}

return status;
}

0 comments on commit c644027

Please sign in to comment.