Show
Ignore:
Timestamp:
10/25/10 12:49:54 (3 years ago)
Author:
saturday06
Message:

xxx

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/objective-cplusplus/i3/trunk/src/mil/tests/Pool2.cc

    r38617 r38620  
     1// -*- coding: utf-8 -*- 
     2 
     3#include <mil/PrecompiledHeaders.h> 
     4#include <mil/Thread.h> 
     5#include <mil/Memory.h> 
     6#include "Test.h" 
     7 
     8using namespace mil::pool; 
     9 
     10class ThreadIdAnd; 
     11 
     12template <int Bytes> 
     13class Memory { 
     14    class { 
     15        uint32_t data; 
     16    public: 
     17        uint16_t getThreadId() { 
     18        } 
     19        uint16_t getBlockCount() { 
     20        } 
     21        void set(uint16_t thread_id, uint16_t block_count) { 
     22        } 
     23    } header; 
     24    char body[Bytes]; 
     25}; 
     26 
     27class Producer { 
     28}; 
     29 
     30class Consumer { 
     31}; 
     32 
     33int next(int *phase, int count) { 
     34    int result = *phase % count; 
     35    *phase = *phase - result; 
     36    return result; 
     37} 
     38 
     39#define check(x) if (!x) {                          \ 
     40        printf("phase%d: %s error\n", phase, #x);   \ 
     41    } 
     42 
     43void test_pool2a(int phase, bool* result) { 
     44    *result = true; 
     45    int bytes = next(&phase, 200); 
     46    if (!phase) { 
     47        *result = false; 
     48        return; 
     49    } 
     50 
     51    { // データが確保されているか軽くチェック 
     52        mil::thread::id_t thread_id = 5; 
     53        Producer p(thread_id); 
     54         
     55    } 
     56     
     57 
     58    return true; 
     59} 
     60 
     61QT_TEST(test_pool2a) { 
     62    for (int phase = 0; ; phase++) { 
     63        bool result = false; 
     64        test_pool2a(phase, &result); 
     65        if (!result) { 
     66            break; 
     67        } 
     68    } 
     69} 
     70