Ejemplo n.º 1
0
static void test_ttm_gettoolinfo(void)
{
    TTTOOLINFOA ti;
    TTTOOLINFOW tiW;
    HWND hwnd;
    DWORD r;

    hwnd = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0,
                           10, 10, 300, 100,
                           NULL, NULL, NULL, 0);

    ti.cbSize = TTTOOLINFOA_V2_SIZE;
    ti.hwnd = NULL;
    ti.hinst = GetModuleHandleA(NULL);
    ti.uFlags = 0;
    ti.uId = 0x1234ABCD;
    ti.lpszText = NULL;
    ti.lParam = 0x1abe11ed;
    GetClientRect(hwnd, &ti.rect);
    r = SendMessageA(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti);
    ok(r, "Adding the tool to the tooltip failed\n");

    ti.cbSize = TTTOOLINFOA_V2_SIZE;
    ti.lParam = 0xaaaaaaaa;
    r = SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&ti);
    ok(r, "Getting tooltip info failed\n");
    ok(0x1abe11ed == ti.lParam ||
       broken(0x1abe11ed != ti.lParam), /* comctl32 < 5.81 */
       "Expected 0x1abe11ed, got %lx\n", ti.lParam);

    tiW.cbSize = TTTOOLINFOW_V2_SIZE;
    tiW.hwnd = NULL;
    tiW.uId = 0x1234ABCD;
    tiW.lParam = 0xaaaaaaaa;
    r = SendMessageA(hwnd, TTM_GETTOOLINFOW, 0, (LPARAM)&tiW);
    ok(r, "Getting tooltip info failed\n");
    ok(0x1abe11ed == tiW.lParam ||
       broken(0x1abe11ed != tiW.lParam), /* comctl32 < 5.81 */
       "Expected 0x1abe11ed, got %lx\n", tiW.lParam);

    ti.cbSize = TTTOOLINFOA_V2_SIZE;
    ti.uId = 0x1234ABCD;
    ti.lParam = 0x55555555;
    SendMessageA(hwnd, TTM_SETTOOLINFOA, 0, (LPARAM)&ti);

    ti.cbSize = TTTOOLINFOA_V2_SIZE;
    ti.lParam = 0xdeadbeef;
    r = SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&ti);
    ok(r, "Getting tooltip info failed\n");
    ok(0x55555555 == ti.lParam ||
       broken(0x55555555 != ti.lParam), /* comctl32 < 5.81 */
       "Expected 0x55555555, got %lx\n", ti.lParam);

    DestroyWindow(hwnd);

    /* 1. test size parameter validation rules (ansi messages) */
    hwnd = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0,
                           10, 10, 300, 100,
                           NULL, NULL, NULL, 0);

    ti.cbSize = TTTOOLINFOA_V1_SIZE - 1;
    ti.hwnd = NULL;
    ti.hinst = GetModuleHandleA(NULL);
    ti.uFlags = 0;
    ti.uId = 0x1234ABCD;
    ti.lpszText = NULL;
    ti.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &ti.rect);
    r = SendMessage(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti);
    ok(r, "Adding the tool to the tooltip failed\n");
    r = SendMessage(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);

    ti.cbSize = TTTOOLINFOA_V1_SIZE - 1;
    ti.hwnd = NULL;
    ti.uId = 0x1234ABCD;
    SendMessage(hwnd, TTM_DELTOOLA, 0, (LPARAM)&ti);
    r = SendMessage(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(0, r);

    ti.cbSize = TTTOOLINFOA_V2_SIZE - 1;
    ti.hwnd = NULL;
    ti.hinst = GetModuleHandleA(NULL);
    ti.uFlags = 0;
    ti.uId = 0x1234ABCD;
    ti.lpszText = NULL;
    ti.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &ti.rect);
    r = SendMessage(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti);
    ok(r, "Adding the tool to the tooltip failed\n");
    r = SendMessage(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);

    ti.cbSize = TTTOOLINFOA_V2_SIZE - 1;
    ti.hwnd = NULL;
    ti.uId = 0x1234ABCD;
    SendMessage(hwnd, TTM_DELTOOLA, 0, (LPARAM)&ti);
    r = SendMessage(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(0, r);

    ti.cbSize = TTTOOLINFOA_V2_SIZE + 1;
    ti.hwnd = NULL;
    ti.hinst = GetModuleHandleA(NULL);
    ti.uFlags = 0;
    ti.uId = 0x1234ABCD;
    ti.lpszText = NULL;
    ti.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &ti.rect);
    r = SendMessage(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti);
    ok(r, "Adding the tool to the tooltip failed\n");
    r = SendMessage(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);

    ti.cbSize = TTTOOLINFOA_V2_SIZE + 1;
    ti.hwnd = NULL;
    ti.uId = 0x1234ABCD;
    SendMessage(hwnd, TTM_DELTOOLA, 0, (LPARAM)&ti);
    r = SendMessage(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(0, r);

    DestroyWindow(hwnd);

    /* 2. test size parameter validation rules (w-messages) */
    hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, 0,
                           10, 10, 300, 100,
                           NULL, NULL, NULL, 0);
    if(!hwnd)
    {
        win_skip("CreateWindowExW() not supported. Skipping.\n");
        return;
    }

    tiW.cbSize = TTTOOLINFOW_V1_SIZE - 1;
    tiW.hwnd = NULL;
    tiW.hinst = GetModuleHandleA(NULL);
    tiW.uFlags = 0;
    tiW.uId = 0x1234ABCD;
    tiW.lpszText = NULL;
    tiW.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &tiW.rect);
    r = SendMessageW(hwnd, TTM_ADDTOOLW, 0, (LPARAM)&tiW);
    ok(r, "Adding the tool to the tooltip failed\n");
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);

    tiW.cbSize = TTTOOLINFOW_V1_SIZE - 1;
    tiW.hwnd = NULL;
    tiW.uId = 0x1234ABCD;
    SendMessageW(hwnd, TTM_DELTOOLW, 0, (LPARAM)&tiW);
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(0, r);

    tiW.cbSize = TTTOOLINFOW_V2_SIZE - 1;
    tiW.hwnd = NULL;
    tiW.hinst = GetModuleHandleA(NULL);
    tiW.uFlags = 0;
    tiW.uId = 0x1234ABCD;
    tiW.lpszText = NULL;
    tiW.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &tiW.rect);
    r = SendMessageW(hwnd, TTM_ADDTOOLW, 0, (LPARAM)&tiW);
    ok(r, "Adding the tool to the tooltip failed\n");
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);

    tiW.cbSize = TTTOOLINFOW_V2_SIZE - 1;
    tiW.hwnd = NULL;
    tiW.uId = 0x1234ABCD;
    SendMessageW(hwnd, TTM_DELTOOLW, 0, (LPARAM)&tiW);
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(0, r);

    tiW.cbSize = TTTOOLINFOW_V2_SIZE + 1;
    tiW.hwnd = NULL;
    tiW.hinst = GetModuleHandleA(NULL);
    tiW.uFlags = 0;
    tiW.uId = 0x1234ABCD;
    tiW.lpszText = NULL;
    tiW.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &tiW.rect);
    r = SendMessageW(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&tiW);
    ok(r, "Adding the tool to the tooltip failed\n");
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);
    /* looks like TTM_DELTOOLW doesn't work with invalid size */
    tiW.cbSize = TTTOOLINFOW_V2_SIZE + 1;
    tiW.hwnd = NULL;
    tiW.uId = 0x1234ABCD;
    SendMessageW(hwnd, TTM_DELTOOLW, 0, (LPARAM)&tiW);
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);

    tiW.cbSize = TTTOOLINFOW_V2_SIZE;
    tiW.hwnd = NULL;
    tiW.uId = 0x1234ABCD;
    SendMessageW(hwnd, TTM_DELTOOLW, 0, (LPARAM)&tiW);
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(0, r);

    DestroyWindow(hwnd);
}
Ejemplo n.º 2
0
static void test_dtm_set_and_get_range(void)
{
    LRESULT r;
    SYSTEMTIME st[2];
    SYSTEMTIME getSt[2];
    HWND hWnd;

    hWnd = create_datetime_control(DTS_SHOWNONE);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    /* initialize st[0] to lowest possible value */
    fill_systime_struct(&st[0], 1601, 1, 0, 1, 0, 0, 0, 0);
    /* initialize st[1] to all invalid numbers */
    fill_systime_struct(&st[1], 0, 0, 7, 0, 24, 60, 60, 1000);

    r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN, (LPARAM)st);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
    ok(r == GDTR_MIN, "Expected %x, not %x(GDTR_MAX) or %x(GDTR_MIN | GDTR_MAX), got %lx\n", GDTR_MIN, GDTR_MAX, GDTR_MIN | GDTR_MAX, r);
    expect_systime(&st[0], &getSt[0]);

    r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MAX, (LPARAM)st);
    expect_unsuccess(0, r);

    /* set st[0] to all invalid numbers */
    fill_systime_struct(&st[0], 0, 0, 7, 0, 24, 60, 60, 1000);
    /* set st[1] to highest possible value */
    fill_systime_struct(&st[1], 30827, 12, 6, 31, 23, 59, 59, 999);

    r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MAX, (LPARAM)st);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
    ok(r == GDTR_MAX, "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MIN | GDTR_MAX), got %lx\n", GDTR_MAX, GDTR_MIN, GDTR_MIN | GDTR_MAX, r);
    expect_systime(&st[1], &getSt[1]);

    r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN, (LPARAM)st);
    expect_unsuccess(0, r);
    r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
    expect_unsuccess(0, r);

    /* set st[0] to highest possible value */
    fill_systime_struct(&st[0], 30827, 12, 6, 31, 23, 59, 59, 999);

    r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
    ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
    expect_systime(&st[0], &getSt[0]);
    expect_systime(&st[1], &getSt[1]);

    /* initialize st[0] to lowest possible value */
    fill_systime_struct(&st[0], 1601, 1, 0, 1, 0, 0, 0, 0);
    /* set st[1] to highest possible value */
    fill_systime_struct(&st[1], 30827, 12, 6, 31, 23, 59, 59, 999);

    r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
    ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
    expect_systime(&st[0], &getSt[0]);
    expect_systime(&st[1], &getSt[1]);

    /* set st[0] to value higher than minimum */
    fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);
    /* set st[1] to value lower than maximum */
    fill_systime_struct(&st[1], 2007, 3, 2, 31, 23, 59, 59, 999);

    r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
    ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
    expect_systime(&st[0], &getSt[0]);
    expect_systime(&st[1], &getSt[1]);

    ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_and_get_range_seq, "test_dtm_set_and_get_range", FALSE);

    /* DTM_SETRANGE with 0 flags */
    r = SendMessageA(hWnd, DTM_SETRANGE, 0, (LPARAM)st);
    ok(r, "got %lu\n", r);
    r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
    ok(r == 0, "got %lu\n", r);
    ok(getSt[0].wYear == 0 && getSt[1].wYear == 0, "got %u, %u\n", getSt[0].wYear, getSt[1].wYear);

    DestroyWindow(hWnd);
}
Ejemplo n.º 3
0
static void test_range(HWND hWndTrackbar){
    int r;

    flush_sequences(sequences, NUM_MSG_SEQUENCE);
    /* test TBM_SETRANGE */
    SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
    expect(10, r);
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
    expect(0, r);
    SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-1, 1000));
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
    expect(1000, r);
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
    expect(-1, r);
    SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(10, 0));
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
    expect(0, r);
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
    expect(10, r);
    SendMessage(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(0,10));
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
    expect(10, r);
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
    expect(0, r);

    /*test TBM_SETRANGEMAX */
    SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 10);
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
    expect(10, r);
    SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, -1);
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
    expect(-1, r);
    SendMessage(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
    expect(10, r);

    /* testing TBM_SETRANGEMIN */
    SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
    expect(0, r);
    SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 10);
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
    expect(10, r);
    SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, -10);
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
    expect(-10, r);
    SendMessage(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 5);
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
    expect(5, r);

    /* test TBM_GETRANGEMAX */
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
    expect(10, r);

    /* test TBM_GETRANGEMIN */
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
    expect(5, r);

    ok_sequence(sequences, TRACKBAR_SEQ_INDEX, range_test_seq, "range test sequence", TRUE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, parent_range_test_seq, "parent range test sequence", TRUE);
}
Ejemplo n.º 4
0
Value InstructionParser::doParse() {
    
    if (context->in_class) {
        return parseClassDeclaration();
    }
    
    if (token_stream->has(Token::OP_ASSIGN)) {
        std::string name = current_token->value;
        expect(Token::NAME);
        expect(Token::OP_ASSIGN);
        
        expression_parser = new ExpressionParser(token_stream, current_token, context);    

        Value lv = expression_parser->parse();
        Value v = context->scope->set(name, lv);
        
        return v;
    }
    
    if (current_token->is(Token::CLASS)) {
        expect(Token::CLASS);
        std::string name = current_token->value;
        expect(Token::NAME);
        
        context->in_class = true;
        context->current_class_name = name;
        
        return NIL_VALUE;
    }
    
    // For now return an expr. has no really different effect than just typing this expr.
    if (current_token->is(Token::RETURN)) {
        expect(Token::RETURN);
        
        if (current_token->is(Token::END_OF_FILE) || current_token->is(Token::END_OF_LINE)) {
            return NIL_VALUE;
        }
        
    }
    
    expression_parser = new ExpressionParser(token_stream, current_token, context);    
    return expression_parser->parse();
    
    // if (current_token->is(Token::NAME)) {
    //     Token* token = current_token;
    //     name = current_token->value;
    //     expect(Token::NAME);
    //     
    //     if (current_token->is(Token::END_OF_LINE) || current_token->is(Token::END_OF_FILE)) {
    //         return context->scope->get(name);
    //     }
    //     
    //     if (context->getClass(name) != NULL) {
    //         return parseMethodCall(name);
    //     } else {
    //         if (current_token->is(Token::OP_ASSIGN)) {
    //             expect(Token::OP_ASSIGN);
    //             
    //             Value lv = doParse();
    //             Value v = context->scope->set(name, lv);
    //             
    //             return v;
    //         }
    //     }
    // }
}
int main(int argc, char *argv[])
{
  createinfo(argc, argv);
  
  int c;
  int nljorder=0;
  int potentialonly=0;
  int cm=0;
  double omega=0.0;

  if (argc < 3) {
    fprintf(stderr, "\nusage: %s interaction slaterdetfile\n"
	    "\n   -s           sort sp states according to n, l, j"
	    "\n   -v           use only potential"
	    "\n   -o OMEGA     use oscillator constant [MeV]"
	    "\n   -c           T-Tcm\n",
	    argv[0]);
    exit(-1);
  }
  
  while((c = getopt(argc, argv, "svco:")) != -1)
    switch (c) {
    case 's':
      nljorder = 1;
      break;
    case 'v':
      potentialonly=1;
      break;
    case 'c':
      cm = 1;
      break;
    case 'o':
      omega = atof(optarg)/hbc;
      break;
    }
  
  char* interactionfile = argv[optind];
  char* slaterdetfile = argv[optind+1];

  Interaction Int;
  if (readInteractionfromFile(&Int, interactionfile))
    exit(-1);
  Int.cm = cm;

  SlaterDet Q;
  if (readSlaterDetfromFile(&Q, slaterdetfile))
    exit(-1);

  // number of nucleons
  int A = Q.A;

  // single-particle overlap matrix
  SlaterDetAux X;
  initSlaterDetAux(&Q, &X);
  calcSlaterDetAux(&Q, &X);

  // Tcm
  double tcm;
  calcTCM(&Q, &X, &tcm);

  // derive oscillator constant from center of mass motion
  double omegacm = 4.0/3.0*tcm;

  if (omega == 0.0)
    omega = omegacm;

  complex double n[A*A];
  copycmat(A, X.n, n);

  // hartree-fock matrix in Gaussian single-particle basis

  complex double hhf[A*A];
  if (potentialonly)	calcPotentialHF(&Int, &Q, &X, hhf);
  else			calcHamiltonianHF(&Int, &Q, &X, hhf);
  
  complex double l2hf[A*A];
  calcl2HF(&Q, &X, l2hf);
  
  complex double j2hf[A*A];
  calcj2HF(&Q, &X, j2hf);

  complex double hoscihf[A*A];
  calcHOsciHF(&Q, &X, omega, hoscihf);

  complex double t3hf[A*A];
  calct3HF(&Q, &X, t3hf);

  complex double parhf[A*A];
  calcparHF(&Q, &X, parhf);

  // solve eigenvalue problem
  complex double lambda[A];
  complex double V[A*A];
  int dim;

  if (nljorder) {
    complex double nljhf[A*A];
    int i;
    for (i=0; i<A*A; i++)
      nljhf[i] = 10000*hoscihf[i]/omega - 100*j2hf[i] + l2hf[i];

      generalizedeigensystem(nljhf, n, A, 0.0, lambda, V, &dim);
  } else
    generalizedeigensystem(hhf, n, A, 0.0, lambda, V, &dim);

  // calculate expectation values
  double norm[A];
  expect(A, n, V, norm);

  double h[A];
  expect(A, hhf, V, h);

  double l2[A];
  expect(A, l2hf, V, l2);
  
  double j2[A];
  expect(A, j2hf, V, j2);

  double hosci[A];
  expect(A, hoscihf, V, hosci);

  double t3[A];
  expect(A, t3hf, V, t3);

  double par[A];
  expect(A, parhf, V, par);

  fprintinfo(stdout);

  // sort single-particle states by energy
  SingleParticleState sp[A];

  int i;
  for (i=0; i<A; i++) {
    sp[i].rank = lambda[i];
    sp[i].e = h[i]/norm[i];
    sp[i].j2 = j2[i]/norm[i];
    sp[i].l2 = l2[i]/norm[i];
    sp[i].hosci = hosci[i]/norm[i];
    sp[i].t3 = t3[i]/norm[i];
    sp[i].pi = par[i]/norm[i];
  }	
  
  qsort(sp, A, sizeof(SingleParticleState), cmpSingleParticleState);
  
  // print proton and neutron levels

  fprintf(stdout, "\nusing oscillator constant: hbar Omega = %8.3f MeV\n",
	  omega*hbc);

  fprintf(stdout, "\nproton levels:\n");
  for (i=0; i<A; i++)
    if (sp[i].t3 > 0.0) {
      fprintf(stdout, "e: %8.3f MeV, j: %5.3f, l: %5.3f, pi: %+5.2f, nosci: %5.3f\n",
	      hbc*sp[i].e, angroot(sp[i].j2), angroot(sp[i].l2), sp[i].pi,
	      sp[i].hosci/omega-1.5);
    }

  fprintf(stdout, "\nneutron levels:\n");
  for (i=0; i<A; i++)
    if (sp[i].t3 < 0.0) {
      fprintf(stdout, "e: %8.3f MeV, j: %5.3f, l: %5.3f, pi: %+5.2f, nosci: %5.3f\n",
	      hbc*sp[i].e, angroot(sp[i].j2), angroot(sp[i].l2), sp[i].pi,
	      sp[i].hosci/omega-1.5);
    }

  return 0;
}
Ejemplo n.º 6
0
static void test_bool(void) {
    expect(0, booltest1(256));
    expect(1, booltest1(257));
    expect(1, booltest2(512));
    expect(1, booltest2(513));
}
Ejemplo n.º 7
0
    void run ()
    {
        testcase ("add/traverse");

        beast::Journal const j;                            // debug journal
        
        tests::TestFamily f(j);

        // h3 and h4 differ only in the leaf, same terminal node (level 19)
        uint256 h1, h2, h3, h4, h5;
        h1.SetHex ("092891fe4ef6cee585fdc6fda0e09eb4d386363158ec3321b8123e5a772c6ca7");
        h2.SetHex ("436ccbac3347baa1f1e53baeef1f43334da88f1f6d70d963b833afd6dfa289fe");
        h3.SetHex ("b92891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e5a772c6ca8");
        h4.SetHex ("b92891fe4ef6cee585fdc6fda2e09eb4d386363158ec3321b8123e5a772c6ca8");
        h5.SetHex ("a92891fe4ef6cee585fdc6fda0e09eb4d386363158ec3321b8123e5a772c6ca7");

        SHAMap sMap (SHAMapType::FREE, f, beast::Journal());
        SHAMapItem i1 (h1, IntToVUC (1)), i2 (h2, IntToVUC (2)), i3 (h3, IntToVUC (3)), i4 (h4, IntToVUC (4)), i5 (h5, IntToVUC (5));
        unexpected (!sMap.addItem (i2, true, false), "no add");
        unexpected (!sMap.addItem (i1, true, false), "no add");

        std::shared_ptr<SHAMapItem> i;
        i = sMap.peekFirstItem ();
        unexpected (!i || (*i != i1), "bad traverse");
        i = sMap.peekNextItem (i->getTag ());
        unexpected (!i || (*i != i2), "bad traverse");
        i = sMap.peekNextItem (i->getTag ());
        unexpected (i, "bad traverse");
        sMap.addItem (i4, true, false);
        sMap.delItem (i2.getTag ());
        sMap.addItem (i3, true, false);
        i = sMap.peekFirstItem ();
        unexpected (!i || (*i != i1), "bad traverse");
        i = sMap.peekNextItem (i->getTag ());
        unexpected (!i || (*i != i3), "bad traverse");
        i = sMap.peekNextItem (i->getTag ());
        unexpected (!i || (*i != i4), "bad traverse");
        i = sMap.peekNextItem (i->getTag ());
        unexpected (i, "bad traverse");

        testcase ("snapshot");
        uint256 mapHash = sMap.getHash ();
        std::shared_ptr<SHAMap> map2 = sMap.snapShot (false);
        unexpected (sMap.getHash () != mapHash, "bad snapshot");
        unexpected (map2->getHash () != mapHash, "bad snapshot");
        unexpected (!sMap.delItem (sMap.peekFirstItem ()->getTag ()), "bad mod");
        unexpected (sMap.getHash () == mapHash, "bad snapshot");
        unexpected (map2->getHash () != mapHash, "bad snapshot");

        testcase ("build/tear");
        {
            std::vector<uint256> keys(8);
            keys[0].SetHex ("b92891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e5a772c6ca8");
            keys[1].SetHex ("b92881fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e5a772c6ca8");
            keys[2].SetHex ("b92691fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e5a772c6ca8");
            keys[3].SetHex ("b92791fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e5a772c6ca8");
            keys[4].SetHex ("b91891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e5a772c6ca8");
            keys[5].SetHex ("b99891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e5a772c6ca8");
            keys[6].SetHex ("f22891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e5a772c6ca8");
            keys[7].SetHex ("292891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e5a772c6ca8");

            std::vector<uint256> hashes(8);
            hashes[0].SetHex ("B7387CFEA0465759ADC718E8C42B52D2309D179B326E239EB5075C64B6281F7F");
            hashes[1].SetHex ("FBC195A9592A54AB44010274163CB6BA95F497EC5BA0A8831845467FB2ECE266");
            hashes[2].SetHex ("4E7D2684B65DFD48937FFB775E20175C43AF0C94066F7D5679F51AE756795B75");
            hashes[3].SetHex ("7A2F312EB203695FFD164E038E281839EEF06A1B99BFC263F3CECC6C74F93E07");
            hashes[4].SetHex ("395A6691A372387A703FB0F2C6D2C405DAF307D0817F8F0E207596462B0E3A3E");
            hashes[5].SetHex ("D044C0A696DE3169CC70AE216A1564D69DE96582865796142CE7D98A84D9DDE4");
            hashes[6].SetHex ("76DCC77C4027309B5A91AD164083264D70B77B5E43E08AEDA5EBF94361143615");
            hashes[7].SetHex ("DF4220E93ADC6F5569063A01B4DC79F8DB9553B6A3222ADE23DEA02BBE7230E5");

            SHAMap map (SHAMapType::FREE, f, beast::Journal());

            expect (map.getHash() == uint256(), "bad initial empty map hash");
            for (int i = 0; i < keys.size(); ++i)
            {
                SHAMapItem item (keys[i], IntToVUC (i));
                map.addItem (item, true, false);
                expect (map.getHash() == hashes[i], "bad buildup map hash");
            }
            for (int i = keys.size() - 1; i >= 0; --i)
            {
                expect (map.getHash() == hashes[i], "bad teardown hash");
                map.delItem (keys[i]);
            }
            expect (map.getHash() == uint256(), "bad final empty map hash");
        }
    }
Ejemplo n.º 8
0
static void test_status_control(void)
{
    HWND hWndStatus;
    int r;
    int nParts[] = {50, 150, -1};
    int checkParts[] = {0, 0, 0};
    int borders[] = {0, 0, 0};
    RECT rc;
    CHAR charArray[20];
    HICON hIcon;
    char ch;
    char chstr[10] = "Inval id";

    hWndStatus = create_status_control(WS_VISIBLE, 0);

    /* Divide into parts and set text */
    r = SendMessage(hWndStatus, SB_SETPARTS, 3, (LPARAM)nParts);
    expect(TRUE,r);
    r = SendMessage(hWndStatus, SB_SETTEXT, 0, (LPARAM)"First");
    expect(TRUE,r);
    r = SendMessage(hWndStatus, SB_SETTEXT, 1, (LPARAM)"Second");
    expect(TRUE,r);
    r = SendMessage(hWndStatus, SB_SETTEXT, 2, (LPARAM)"Third");
    expect(TRUE,r);

    /* Get RECT Information */
    r = SendMessage(hWndStatus, SB_GETRECT, 0, (LPARAM)&rc);
    expect(TRUE,r);
    expect(2,rc.top);
    /* The rc.bottom test is system dependent
    expect(22,rc.bottom); */
    expect(0,rc.left);
    expect(50,rc.right);
    r = SendMessage(hWndStatus, SB_GETRECT, -1, (LPARAM)&rc);
    expect(FALSE,r);
    r = SendMessage(hWndStatus, SB_GETRECT, 3, (LPARAM)&rc);
    expect(FALSE,r);
    /* Get text length and text */
    r = SendMessage(hWndStatus, SB_GETTEXTLENGTH, 2, 0);
    expect(5,LOWORD(r));
    expect(0,HIWORD(r));
    r = SendMessage(hWndStatus, SB_GETTEXT, 2, (LPARAM) charArray);
    ok(strcmp(charArray,"Third") == 0, "Expected Third, got %s\n", charArray);
    expect(5,LOWORD(r));
    expect(0,HIWORD(r));

    /* Get parts and borders */
    r = SendMessage(hWndStatus, SB_GETPARTS, 3, (LPARAM)checkParts);
    ok(r == 3, "Expected 3, got %d\n", r);
    expect(50,checkParts[0]);
    expect(150,checkParts[1]);
    expect(-1,checkParts[2]);
    r = SendMessage(hWndStatus, SB_GETBORDERS, 0, (LPARAM)borders);
    ok(r == TRUE, "Expected TRUE, got %d\n", r);
    expect(0,borders[0]);
    expect(2,borders[1]);
    expect(2,borders[2]);

    /* Test resetting text with different characters */
    r = SendMessage(hWndStatus, SB_SETTEXT, 0, (LPARAM)"First@Again");
    expect(TRUE,r);
    r = SendMessage(hWndStatus, SB_SETTEXT, 1, (LPARAM)"Invalid\tChars\\7\7");
        expect(TRUE,r);
    r = SendMessage(hWndStatus, SB_SETTEXT, 2, (LPARAM)"InvalidChars\\n\n");
        expect(TRUE,r);

    /* Get text again */
    r = SendMessage(hWndStatus, SB_GETTEXT, 0, (LPARAM) charArray);
    ok(strcmp(charArray,"First@Again") == 0, "Expected First@Again, got %s\n", charArray);
    expect(11,LOWORD(r));
    expect(0,HIWORD(r));
    r = SendMessage(hWndStatus, SB_GETTEXT, 1, (LPARAM) charArray);
    ok(strcmp(charArray,"Invalid\tChars\\7 ") == 0, "Expected Invalid\tChars\\7 , got %s\n", charArray);

    expect(16,LOWORD(r));
    expect(0,HIWORD(r));
    r = SendMessage(hWndStatus, SB_GETTEXT, 2, (LPARAM) charArray);
    ok(strcmp(charArray,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray);

    expect(15,LOWORD(r));
    expect(0,HIWORD(r));

    /* test more nonprintable chars */
    for(ch = 0x00; ch < 0x7F; ch++) {
        chstr[5] = ch;
        r = SendMessage(hWndStatus, SB_SETTEXT, 0, (LPARAM)chstr);
        expect(TRUE,r);
        r = SendMessage(hWndStatus, SB_GETTEXT, 0, (LPARAM)charArray);
        /* substitution with single space */
        if (ch > 0x00 && ch < 0x20 && ch != '\t')
            chstr[5] = ' ';
        ok(strcmp(charArray, chstr) == 0, "Expected %s, got %s\n", chstr, charArray);
    }

    /* Set background color */
    r = SendMessage(hWndStatus, SB_SETBKCOLOR , 0, RGB(255,0,0));
    ok(r == CLR_DEFAULT ||
       broken(r == 0), /* win95 */
       "Expected %d, got %d\n", CLR_DEFAULT, r);
    r = SendMessage(hWndStatus, SB_SETBKCOLOR , 0, CLR_DEFAULT);
    ok(r == RGB(255,0,0) ||
       broken(r == 0), /* win95 */
       "Expected %d, got %d\n", RGB(255,0,0), r);

    /* Add an icon to the status bar */
    hIcon = LoadIcon(NULL, IDI_QUESTION);
    r = SendMessage(hWndStatus, SB_SETICON, 1, 0);
    ok(r != 0 ||
       broken(r == 0), /* win95 */
       "Expected non-zero, got %d\n", r);
    r = SendMessage(hWndStatus, SB_SETICON, 1, (LPARAM) hIcon);
    ok(r != 0 ||
       broken(r == 0), /* win95 */
       "Expected non-zero, got %d\n", r);
    r = SendMessage(hWndStatus, SB_SETICON, 1, 0);
    ok(r != 0 ||
       broken(r == 0), /* win95 */
       "Expected non-zero, got %d\n", r);

    /* Set the Unicode format */
    r = SendMessage(hWndStatus, SB_SETUNICODEFORMAT, FALSE, 0);
    r = SendMessage(hWndStatus, SB_GETUNICODEFORMAT, 0, 0);
    expect(FALSE,r);
    r = SendMessage(hWndStatus, SB_SETUNICODEFORMAT, TRUE, 0);
    expect(FALSE,r);
    r = SendMessage(hWndStatus, SB_GETUNICODEFORMAT, 0, 0);
    ok(r == TRUE ||
       broken(r == FALSE), /* win95 */
       "Expected TRUE, got %d\n", r);

    /* Reset number of parts */
    r = SendMessage(hWndStatus, SB_SETPARTS, 2, (LPARAM)nParts);
    expect(TRUE,r);

    /* Set the minimum height and get rectangle information again */
    SendMessage(hWndStatus, SB_SETMINHEIGHT, 50, 0);
    r = SendMessage(hWndStatus, WM_SIZE, 0, 0);
    expect(0,r);
    r = SendMessage(hWndStatus, SB_GETRECT, 0, (LPARAM)&rc);
    expect(TRUE,r);
    expect(2,rc.top);
    /* The rc.bottom test is system dependent
    expect(22,rc.bottom); */
    expect(0,rc.left);
    expect(50,rc.right);
    r = SendMessage(hWndStatus, SB_GETRECT, -1, (LPARAM)&rc);
    expect(FALSE,r);
    r = SendMessage(hWndStatus, SB_GETRECT, 3, (LPARAM)&rc);
    expect(FALSE,r);

    /* Set the ToolTip text */
    todo_wine
    {
        SendMessage(hWndStatus, SB_SETTIPTEXT, 0,(LPARAM) "Tooltip Text");
        lstrcpyA(charArray, "apple");
        SendMessage(hWndStatus, SB_GETTIPTEXT, MAKEWPARAM (0, 20),(LPARAM) charArray);
        ok(strcmp(charArray,"Tooltip Text") == 0 ||
           broken(!strcmp(charArray, "apple")), /* win95 */
           "Expected Tooltip Text, got %s\n", charArray);
    }

    /* Make simple */
    SendMessage(hWndStatus, SB_SIMPLE, TRUE, 0);
    r = SendMessage(hWndStatus, SB_ISSIMPLE, 0, 0);
    ok(r == TRUE ||
       broken(r == FALSE), /* win95 */
       "Expected TRUE, got %d\n", r);

    DestroyWindow(hWndStatus);
}
static void test_mutable_string_copy(void)
{
	MutableString* ms = mutable_string_new("Ryan");
	expect(ms != NULL);
	expect(ms->capacity == 5);
	expect(ms->length == 4);
	expect(ms->buffer != NULL);
	expect(str_equal("Ryan", ms->buffer));
	expect(ms->buffer[ms->length] == '\0');

	MutableString* copy;
	copy = mutable_string_copy(ms);

	expect(copy != NULL);
	expect(copy->capacity == 5);
	expect(copy->length == 4);
	expect(copy->buffer != NULL);
	expect(str_equal("Ryan", copy->buffer));
	expect(copy->buffer[copy->length] == '\0');

	mutable_string_free(ms);
	mutable_string_free(copy);

}
Ejemplo n.º 10
0
Archivo: xpal.c Proyecto: kahrs/cda
rdata(void)
{
	char c;
	char *xcp;
	char *cmdlinepart = "";
	int s, pindex, ipin;
	long v;

loop:
	s = symb();
	if(s == EON) {
		(void) postamble();
		return 1;
	}
	if(s == EXTERN) {
		if (extern_id && strlen(extern_id) > 0) { /* seen -t */
			cmdlinepart = malloc(strlen(extern_id) + 1);
			strcpy(cmdlinepart, extern_id);
		}
		else	extern_id = malloc(STRLEN);
		while(isspace(c = gchar()));
		xcp = extern_id;
		*xcp++ = toupper(c);
		while((c = gchar()) != '\n') *xcp++ = toupper(c);
		*xcp = '\0';
		if (strlen(cmdlinepart) > 0)
			if (strcmp(cmdlinepart, extern_id) != 0)
				fprint(2, "warning: -t %s and .x %s don't agree\n", cmdlinepart, extern_id);
			else;
		else (void) rdlibrary();
		goto loop;
	}
	if(s == ITER) {
		fprint(2, ".r");
		for(;;) {
			c = gchar();
			if(c < 0)
				goto loop;
			fprint(2, "%c", (char) c);
			if(c == '\n')
				goto loop;
		}
	}
	if(s != OUT)
		expect(".o");
	if (!extern_id || (strlen(extern_id) == 0)) expect(".x");
	s = symb();
	if(s != NUMB)
		expect("output pin");
	opin = numb;
	if (opin > MAXPIN) {
		fprint(2, "output pin %d > MAXPIN! Time to recompile!\n", opin);
		exit(1);
	}
	if (!(pin_array[opin].properties & OUTPUT_TYPE))
		fprint(2, "output pin %d not found\n", opin);
	if (pin_array[opin].flags & USED_FLAG)
		fprint(2, "pin %d already used\n", opin);
	pin_array[opin].flags |= USED_FLAG;
	if (iflag)
		fprint(2, "\n.o %d", opin);
	for(pindex=0;;) {
		s = symb();
		if(s != NUMB) break;
/*??*/
		if(s == NAME) {
			fprint(2, "name %s unexpected", name);
			continue;
		}
		ipin = numb;
		if (!(pin_array[ipin].properties & INPUT_TYPE)) {
			fprint(2, "pin %d isn't an input\n", ipin);
			continue;
		}
		if (pindex > NINPUTS) {
			fprint(2, "too many inputs (NINPUTS too small)\n");
			exit(0);
		}
		input_pin[pindex++] = ipin;
		if (iflag)
			fprint(2, " %d", ipin);
	}
	input_pin[pindex] = 0;
	if (iflag)
		fprint(2, "\n");
	if(s != LINE)
		expect("new line");
	nimp = 0;
	for(;;) {
		s = symb();
		if(s == LINE)
			continue;
		if(s != NUMB)
			break;
		v = numb;
		c = symb();
		if(c != COLON && c != PERC)
			expect(":");
		s = symb();
		if(s != NUMB)
			expect("number");
		if(c == PERC) {
			expect("code for %"); /* tee hee */
			continue;
		}
		if(nimp >= NIMP) {
			fprint(2, "buffer[IMP] too small\n");
			exit(1);
		}
		if (iflag)
			fprint(2, " %d:%d", v, numb);
		imp[nimp].val = v;
		imp[nimp].mask = numb;
		nimp++;
	}
	if (iflag)
		fprint(2, "\n");
	peeks = s;
	return 0;
}
Ejemplo n.º 11
0
    void runTestInitialisation()
    {
        beginTest ("Int32");
        {
            int value = 123456789;

            OSCArgument arg (value);

            expect (arg.getType() == OSCTypes::int32);

            expect (arg.isInt32());
            expect (! arg.isFloat32());
            expect (! arg.isString());
            expect (! arg.isBlob());

            expect (arg.getInt32() == value);
        }

        beginTest ("Float32");
        {
            float value = 12345.6789f;

            OSCArgument arg (value);

            expect (arg.getType() == OSCTypes::float32);

            expect (! arg.isInt32());
            expect (arg.isFloat32());
            expect (! arg.isString());
            expect (! arg.isBlob());

            expect (arg.getFloat32() == value);


        }

        beginTest ("String");
        {
            String value = "Hello, World!";
            OSCArgument arg (value);

            expect (arg.getType() == OSCTypes::string);

            expect (! arg.isInt32());
            expect (! arg.isFloat32());
            expect (arg.isString());
            expect (! arg.isBlob());

            expect (arg.getString() == value);
        }

        beginTest ("String (from C string)");
        {
            OSCArgument arg ("Hello, World!");

            expect (arg.getType() == OSCTypes::string);

            expect (! arg.isInt32());
            expect (! arg.isFloat32());
            expect (arg.isString());
            expect (! arg.isBlob());

            expect (arg.getString() == String ("Hello, World!"));
        }

        beginTest ("Blob");
        {
            const size_t numBytes = 412;
            MemoryBlock blob = getMemoryBlockWithRandomData (numBytes);

            OSCArgument arg (blob);

            expect (arg.getType() == OSCTypes::blob);

            expect (! arg.isInt32());
            expect (! arg.isFloat32());
            expect (! arg.isString());
            expect (arg.isBlob());

            expect (arg.getBlob() == blob);
        }

        beginTest ("Copy, move and assignment");
        {
            {
                int value = -42;
                OSCArgument arg (value);

                OSCArgument copy = arg;
                expect (copy.getType() == OSCTypes::int32);
                expect (copy.getInt32() == value);

                OSCArgument assignment ("this will be overwritten!");
                assignment = copy;
                expect (assignment.getType() == OSCTypes::int32);
                expect (assignment.getInt32() == value);
           }
           {
                const size_t numBytes = 412;
                MemoryBlock blob = getMemoryBlockWithRandomData (numBytes);
                OSCArgument arg (blob);

                OSCArgument copy = arg;
                expect (copy.getType() == OSCTypes::blob);
                expect (copy.getBlob() == blob);

                OSCArgument assignment ("this will be overwritten!");
                assignment = copy;
                expect (assignment.getType() == OSCTypes::blob);
                expect (assignment.getBlob() == blob);
           }
        }
    }
Ejemplo n.º 12
0
static void test_tic_settings(HWND hWndTrackbar){
    int r;

    /* testing TBM_SETTIC */
    /* Set tics at 5 and 10 */
    /* 0 and 20 are out of range and should not be set */
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0, 0);
    expect(10, r);
    r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0, 0);
    expect(5, r);

    flush_sequences(sequences, NUM_MSG_SEQUENCE);
    r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 0);
    ok(r == FALSE, "Expected FALSE, got %d\n", r);
    r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 5);
    ok(r == TRUE, "Expected TRUE, got %d\n", r);
    r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 10);
    ok(r == TRUE, "Expected TRUE, got %d\n", r);

    r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 20);
    ok(r == FALSE, "Expected False, got %d\n", r);

    /* test TBM_SETTICFREQ */
    SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
    SendMessage(hWndTrackbar, TBM_SETTICFREQ, 2, 0);
    r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
    expect(6, r);
    SendMessage(hWndTrackbar, TBM_SETTICFREQ, 5, 0);
    r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
    expect(3, r);
    SendMessage(hWndTrackbar, TBM_SETTICFREQ, 15, 0);
    r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
    expect(2, r);

    /* test TBM_GETNUMTICS */
    /* since TIC FREQ is 15, there should be only 2 tics now */
    r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
    expect(2, r);

    ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_settings_test_seq, "tic settings test sequence", TRUE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, parent_tic_settings_test_seq, "parent tic settings test sequence", TRUE);

    /* range [0,0], freq = 1 */
    SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 0);
    SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
    SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
    r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
    expect(2, r);
    /* range [0,1], freq = 1 */
    SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 1);
    SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
    SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
    r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
    expect(2, r);
    /* range [0,2], freq = 1 */
    SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 2);
    SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
    SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
    r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
    expect(3, r);
}
Ejemplo n.º 13
0
static void test_selection(HWND hWndTrackbar){
    int r;

    flush_sequences(sequences, NUM_MSG_SEQUENCE);
    /* test TBM_SETSEL */
    SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
    r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
    expect(10, r);
    r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
    expect(5, r);
    SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(5, 20));
    r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
    expect(10, r);
    r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
    expect(5, r);
    SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(5, 10));
    r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
    expect(10, r);
    r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
    expect(5, r);

    /* test TBM_SETSELEND */
    SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
    r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
    expect(10, r);
    SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 20);
    r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
    expect(10, r);
    SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 4);
    r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
    expect(4, r);
    SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 2);
    r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
    expect(2, r);

    /* test TBM_GETSELEND */
    r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
    expect(2, r);

    /* testing TBM_SETSELSTART */
    SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 5);
    r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
    expect(5, r);
    SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
    r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
    expect(5, r);
    SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 20);
    r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
    expect(20, r);
    SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 8);
    r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
    expect(8, r);

    /* test TBM_GETSELSTART */
    r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
    expect(8, r);

    ok_sequence(sequences, TRACKBAR_SEQ_INDEX, selection_test_seq, "selection test sequence", TRUE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, parent_selection_test_seq, "parent selection test sequence", TRUE);
}
Ejemplo n.º 14
0
/* when max<min for DTM_SETRANGE, Windows seems to swap the min and max values,
although that's undocumented.  However, it doesn't seem to be implemented
correctly, causing some strange side effects */
static void test_dtm_set_range_swap_min_max(void)
{
    LRESULT r;
    SYSTEMTIME st[2];
    SYSTEMTIME getSt[2];
    SYSTEMTIME origSt;
    HWND hWnd;

    hWnd = create_datetime_control(DTS_SHOWNONE);
    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    fill_systime_struct(&st[0], 2007, 2, 4, 15, 2, 2, 2, 2);

    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st[0]);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&origSt);
    ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
    expect_systime(&st[0], &origSt);

    /* set st[0] to value higher than st[1] */
    fill_systime_struct(&st[0], 2007, 3, 2, 31, 23, 59, 59, 999);
    fill_systime_struct(&st[1], 1980, 1, 3, 23, 14, 34, 37, 465);

    /* since min>max, min and max values should be swapped by DTM_SETRANGE
    automatically */
    r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
    ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
    todo_wine {
        ok(compare_systime(&st[0], &getSt[0]) == 1 ||
           broken(compare_systime(&st[0], &getSt[1]) == 1), /* comctl32 version  <= 5.80 */
           "ST1 != ST2\n");

        ok(compare_systime(&st[1], &getSt[1]) == 1 ||
           broken(compare_systime(&st[1], &getSt[0]) == 1), /* comctl32 version  <= 5.80 */
           "ST1 != ST2\n");
    }

    fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);

    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st[0]);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt[0]);
    ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
    /* the time part seems to not change after swapping the min and max values
    and doing DTM_SETSYSTEMTIME */
    expect_systime_date(&st[0], &getSt[0]);
    todo_wine {
        ok(compare_systime_time(&origSt, &getSt[0]) == 1 ||
           broken(compare_systime_time(&st[0], &getSt[0]) == 1), /* comctl32 version  <= 5.80 */
           "ST1.time != ST2.time\n");
    }

    /* set st[0] to value higher than minimum */
    fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);
    /* set st[1] to value lower than maximum */
    fill_systime_struct(&st[1], 2007, 3, 2, 31, 23, 59, 59, 999);

    r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
    expect(1, r);
    /* for some reason after we swapped the min and max values before,
    whenever we do a DTM_SETRANGE, the DTM_GETRANGE will return the values
    swapped*/
    r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
    ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
    todo_wine {
        ok(compare_systime(&st[0], &getSt[1]) == 1 ||
           broken(compare_systime(&st[0], &getSt[0]) == 1), /* comctl32 version  <= 5.80 */
           "ST1 != ST2\n");

        ok(compare_systime(&st[1], &getSt[0]) == 1 ||
           broken(compare_systime(&st[1], &getSt[1]) == 1), /* comctl32 version <= 5.80 */
           "ST1 != ST2\n");
    }

    /* set st[0] to value higher than st[1] */
    fill_systime_struct(&st[0], 2007, 3, 2, 31, 23, 59, 59, 999);
    fill_systime_struct(&st[1], 1980, 1, 3, 23, 14, 34, 37, 465);

    /* set min>max again, so that the return values of DTM_GETRANGE are no
    longer swapped the next time we do a DTM SETRANGE and DTM_GETRANGE*/
    r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
    ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
    expect_systime(&st[0], &getSt[1]);
    expect_systime(&st[1], &getSt[0]);

    /* initialize st[0] to lowest possible value */
    fill_systime_struct(&st[0], 1601, 1, 0, 1, 0, 0, 0, 0);
    /* set st[1] to highest possible value */
    fill_systime_struct(&st[1], 30827, 12, 6, 31, 23, 59, 59, 999);

    r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
    ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
    expect_systime(&st[0], &getSt[0]);
    expect_systime(&st[1], &getSt[1]);

    ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_range_swap_min_max_seq, "test_dtm_set_range_swap_min_max", FALSE);

    DestroyWindow(hWnd);
}
Ejemplo n.º 15
0
int main(int argc, char *argv[])
{
	int p[2];
	int stdoutfd;

	setbuf(stdout, 0);
	printf("1..1\n");
	stderrfd = dup(STDERR_FILENO);
	if (stderrfd < 0)
		err(1, "dup of stderr failed");

	stdoutfd = dup(STDOUT_FILENO);
	if (stdoutfd < 0)
		err(1, "dup of stdout failed");

	if (pipe(p) != 0)
		failmsg("pipe failed");

	if (dup2(p[1], STDERR_FILENO) < 0 || dup2(p[1], STDOUT_FILENO) < 0)
		failmsg("Duplicating file descriptor");

	plan_tests(10);
	expect(p[0], "1..10\n");

	ok(1, "msg1");
	expect(p[0], "ok 1 - msg1\n");

	ok(0, "msg2");
	expect(p[0], "not ok 2 - msg2\n"
	       "#     Failed test (*test/run.c:main() at line 91)\n");

	ok1(true);
	expect(p[0], "ok 3 - true\n");

	ok1(false);
 	expect(p[0], "not ok 4 - false\n"
	       "#     Failed test (*test/run.c:main() at line 98)\n");

	pass("passed");
 	expect(p[0], "ok 5 - passed\n");

	fail("failed");
 	expect(p[0], "not ok 6 - failed\n"
	       "#     Failed test (*test/run.c:main() at line 105)\n");

	skip(2, "skipping %s", "test");
 	expect(p[0], "ok 7 # skip skipping test\n"
	       "ok 8 # skip skipping test\n");

	todo_start("todo");
	ok1(false);
	expect(p[0], "not ok 9 - false # TODO todo\n"
	       "#     Failed (TODO) test (*test/run.c:main() at line 114)\n");
	ok1(true);
	expect(p[0], "ok 10 - true # TODO todo\n");
	todo_end();

	if (exit_status() != 3)
		failmsg("Expected exit status 3, not %i", exit_status());

#if 0
	/* Manually run the atexit command. */
	_cleanup();
	expect(p[0], "# Looks like you failed 2 tests of 9.\n");
#endif

	write_all(stdoutfd, "ok 1 - All passed\n",
		  strlen("ok 1 - All passed\n"));
	exit(0);
}
Ejemplo n.º 16
0
static void test_dtm_set_and_get_system_time(void)
{
    LRESULT r;
    SYSTEMTIME st, getSt, ref;
    HWND hWnd;

    hWnd = create_datetime_control(0);
    ok(hWnd !=NULL, "Expected non NULL, got %p\n", hWnd);
    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_NONE, (LPARAM)&st);
    expect(0, r);

    DestroyWindow(hWnd);

    hWnd = create_datetime_control(DTS_SHOWNONE);
    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_NONE, (LPARAM)&st);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
    ok(r == GDT_NONE, "Expected %d, not %d(GDT_VALID) or %d(GDT_ERROR), got %ld\n", GDT_NONE, GDT_VALID, GDT_ERROR, r);

    /* set st to lowest possible value */
    fill_systime_struct(&st, 1601, 1, 0, 1, 0, 0, 0, 0);

    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    expect(1, r);

    /* set st to highest possible value */
    fill_systime_struct(&st, 30827, 12, 6, 31, 23, 59, 59, 999);

    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    expect(1, r);

    /* set st to value between min and max */
    fill_systime_struct(&st, 1980, 1, 3, 23, 14, 34, 37, 465);

    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
    ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
    expect_systime(&st, &getSt);

    /* set st to invalid value */
    fill_systime_struct(&st, 0, 0, 7, 0, 24, 60, 60, 1000);

    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    expect_unsuccess(0, r);

    ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_and_get_system_time_seq, "test_dtm_set_and_get_system_time", FALSE);

    /* set to some valid value */
    GetSystemTime(&ref);
    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&ref);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
    expect(GDT_VALID, r);
    expect_systime(&ref, &getSt);

    /* year invalid */
    st = ref;
    st.wYear = 0;
    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    todo_wine expect(1, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
    expect(GDT_VALID, r);
    expect_systime(&ref, &getSt);
    /* month invalid */
    st = ref;
    st.wMonth = 13;
    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    expect(0, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
    expect(GDT_VALID, r);
    expect_systime(&ref, &getSt);
    /* day invalid */
    st = ref;
    st.wDay = 32;
    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    expect(0, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
    expect(GDT_VALID, r);
    expect_systime(&ref, &getSt);
    /* day invalid for current month */
    st = ref;
    st.wDay = 30;
    st.wMonth = 2;
    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    expect(0, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
    expect(GDT_VALID, r);
    expect_systime(&ref, &getSt);
    /* day of week isn't validated */
    st = ref;
    st.wDayOfWeek = 10;
    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
    expect(GDT_VALID, r);
    expect_systime(&ref, &getSt);
    /* hour invalid */
    st = ref;
    st.wHour = 25;
    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    expect(0, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
    expect(GDT_VALID, r);
    expect_systime(&ref, &getSt);
    /* minute invalid */
    st = ref;
    st.wMinute = 60;
    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    expect(0, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
    expect(GDT_VALID, r);
    expect_systime(&ref, &getSt);
    /* sec invalid */
    st = ref;
    st.wSecond = 60;
    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    expect(0, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
    expect(GDT_VALID, r);
    expect_systime(&ref, &getSt);
    /* msec invalid */
    st = ref;
    st.wMilliseconds = 1000;
    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    expect(0, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
    expect(GDT_VALID, r);
    expect_systime(&ref, &getSt);

    /* day of week should be calculated automatically,
       actual day of week for this date is 4 */
    fill_systime_struct(&st, 2009, 10, 1, 1, 0, 0, 10, 200);
    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
    expect(1, r);
    r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
    expect(GDT_VALID, r);
    /* 01.10.2009 is Thursday */
    expect(4, (LRESULT)getSt.wDayOfWeek);
    st.wDayOfWeek = 4;
    expect_systime(&st, &getSt);
}
Ejemplo n.º 17
0
static void test_updown_pos(void)
{
    HWND updown;
    int r;

    updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    /* Set Range from 0 to 100 */
    SendMessageA(updown, UDM_SETRANGE, 0 , MAKELONG(100,0) );
    r = SendMessageA(updown, UDM_GETRANGE, 0,0);
    expect(100,LOWORD(r));
    expect(0,HIWORD(r));

    /* Set the position to 5, return is not checked as it was set before func call */
    SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(5,0) );
    /* Since UDM_SETBUDDYINT was not set at creation HIWORD(r) will always be 1 as a return from UDM_GETPOS */
    /* Get the position, which should be 5 */
    r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
    expect(5,LOWORD(r));
    expect(1,HIWORD(r));

    /* Set the position to 0, return should be 5 */
    r = SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(0,0) );
    expect(5,r);
    /* Get the position, which should be 0 */
    r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
    expect(0,LOWORD(r));
    expect(1,HIWORD(r));

    /* Set the position to -1, return should be 0 */
    r = SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(-1,0) );
    expect(0,r);
    /* Get the position, which should be 0 */
    r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
    expect(0,LOWORD(r));
    expect(1,HIWORD(r));

    /* Set the position to 100, return should be 0 */
    r = SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(100,0) );
    expect(0,r);
    /* Get the position, which should be 100 */
    r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
    expect(100,LOWORD(r));
    expect(1,HIWORD(r));

    /* Set the position to 101, return should be 100 */
    r = SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(101,0) );
    expect(100,r);
    /* Get the position, which should be 100 */
    r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
    expect(100,LOWORD(r));
    expect(1,HIWORD(r));

    ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_pos_seq , "test updown pos", FALSE);

    DestroyWindow(updown);

    /* there's no attempt to update buddy Edit if text didn't change */
    SetWindowTextA(g_edit, "50");
    updown = create_updown_control(UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_ARROWKEYS, g_edit);

    /* test sequence only on 5.8x versions */
    r = SendMessageA(updown, UDM_GETPOS32, 0, 0);
    if (r)
    {
        UDACCEL accel;

        flush_sequences(sequences, NUM_MSG_SEQUENCES);

        r = SendMessageA(updown, UDM_SETPOS, 0, 50);
        expect(50,r);

        ok_sequence(sequences, EDIT_SEQ_INDEX, test_updown_pos_nochange_seq,
                    "test updown pos, no change", FALSE);

        SendMessageA(updown, UDM_SETRANGE, 0, MAKELONG(1, 40));
        r = SendMessageA(updown, UDM_GETRANGE, 0, 0);
        expect(1, LOWORD(r));
        expect(40, HIWORD(r));

        accel.nSec = 0;
        accel.nInc = 5;
        r = SendMessageA(updown, UDM_SETACCEL, 1, (LPARAM)&accel);
        expect(TRUE, r);

        r = SendMessageA(updown, UDM_GETPOS, 0, 0);
        expect(40, LOWORD(r));
        expect(1, HIWORD(r));

        r = SendMessageA(updown, UDM_SETPOS, 0, MAKELONG(0, 0));
        expect(40, LOWORD(r));
        expect(0, HIWORD(r));

        r = SendMessageA(updown, UDM_GETPOS, 0, 0);
        expect(1, LOWORD(r));
        expect(0, HIWORD(r));

        r = SendMessageA(updown, UDM_SETPOS, 0, MAKELONG(2, 0));
        expect(1, LOWORD(r));
        expect(0, HIWORD(r));

        r = SendMessageA(g_edit, WM_KEYDOWN, VK_UP, 0);
        expect(0, r);
        r = SendMessageA(updown, UDM_GETPOS, 0, 0);
        expect(1, LOWORD(r));
        expect(0, HIWORD(r));

        r = SendMessageA(updown, UDM_SETPOS, 0, MAKELONG(50, 0));
        expect(1, LOWORD(r));
        expect(0, HIWORD(r));

        r = SendMessageA(updown, UDM_GETPOS, 0, 0);
        expect(40, LOWORD(r));
        expect(0, HIWORD(r));
    }

    DestroyWindow(updown);
}
Ejemplo n.º 18
0
    void testVersionPacking ()
    {
        testcase ("version packing");

        expect (to_packed (from_version (0, 0)) == 0);
        expect (to_packed (from_version (0, 1)) == 1);
        expect (to_packed (from_version (0, 255)) == 255);
        expect (to_packed (from_version (0, 65535)) == 65535);

        expect (to_packed (from_version (1, 0)) == 65536);
        expect (to_packed (from_version (1, 1)) == 65537);
        expect (to_packed (from_version (1, 255)) == 65791);
        expect (to_packed (from_version (1, 65535)) == 131071);

        expect (to_packed (from_version (255, 0)) == 16711680);
        expect (to_packed (from_version (255, 1)) == 16711681);
        expect (to_packed (from_version (255, 255)) == 16711935);
        expect (to_packed (from_version (255, 65535)) == 16777215);

        expect (to_packed (from_version (65535, 0)) == 4294901760);
        expect (to_packed (from_version (65535, 1)) == 4294901761);
        expect (to_packed (from_version (65535, 255)) == 4294902015);
        expect (to_packed (from_version (65535, 65535)) == 4294967295);
    }
Ejemplo n.º 19
0
static void test_updown_pos32(void)
{
    HWND updown;
    int r;
    int low, high;

    updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    /* Set the position to 0 to 1000 */
    SendMessageA(updown, UDM_SETRANGE32, 0 , 1000 );

    low = high = -1;
    r = SendMessageA(updown, UDM_GETRANGE32, (WPARAM) &low , (LPARAM) &high );
    expect(0,r);
    if (low == -1)
    {
        win_skip("UDM_SETRANGE32/UDM_GETRANGE32 not available\n");
        DestroyWindow(updown);
        return;
    }

    expect(0,low);
    expect(1000,high);

    /* Set position to 500 */
    r = SendMessageA(updown, UDM_SETPOS32, 0 , 500 );
    if (!r)
    {
        win_skip("UDM_SETPOS32 and UDM_GETPOS32 need 5.80\n");
        DestroyWindow(updown);
        return;
    }
    expect(50,r);

    /* Since UDM_SETBUDDYINT was not set at creation bRet will always be true as a return from UDM_GETPOS32 */

    r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
    expect(500,r);
    expect(1,high);

    /* Set position to 0, return should be 500 */
    r = SendMessageA(updown, UDM_SETPOS32, 0 , 0 );
    expect(500,r);
    r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
    expect(0,r);
    expect(1,high);

    /* Set position to -1 which should become 0, return should be 0 */
    r = SendMessageA(updown, UDM_SETPOS32, 0 , -1 );
    expect(0,r);
    r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
    expect(0,r);
    expect(1,high);

    /* Set position to 1000, return should be 0 */
    r = SendMessageA(updown, UDM_SETPOS32, 0 , 1000 );
    expect(0,r);
    r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
    expect(1000,r);
    expect(1,high);

    /* Set position to 1001 which should become 1000, return should be 1000 */
    r = SendMessageA(updown, UDM_SETPOS32, 0 , 1001 );
    expect(1000,r);
    r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
    expect(1000,r);
    expect(1,high);

    ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_pos32_seq, "test updown pos32", FALSE);

    DestroyWindow(updown);

    /* there's no attempt to update buddy Edit if text didn't change */
    SetWindowTextA(g_edit, "50");
    updown = create_updown_control(UDS_ALIGNRIGHT | UDS_SETBUDDYINT, g_edit);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    r = SendMessageA(updown, UDM_SETPOS32, 0, 50);
    expect(50,r);
    ok_sequence(sequences, EDIT_SEQ_INDEX, test_updown_pos_nochange_seq,
                "test updown pos, no change", FALSE);

    DestroyWindow(updown);
}
Ejemplo n.º 20
0
static void t2(int a) {
    expect(79, a);
}
Ejemplo n.º 21
0
static void test_updown_base(void)
{
    HWND updown;
    int r;
    CHAR text[10];

    updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    SendMessageA(updown, UDM_SETBASE, 10 , 0);
    r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
    expect(10,r);

    /* Set base to an invalid value, should return 0 and stay at 10 */
    r = SendMessageA(updown, UDM_SETBASE, 80 , 0);
    expect(0,r);
    r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
    expect(10,r);

    /* Set base to 16 now, should get 16 as the return */
    r = SendMessageA(updown, UDM_SETBASE, 16 , 0);
    expect(10,r);
    r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
    expect(16,r);

    /* Set base to an invalid value, should return 0 and stay at 16 */
    r = SendMessageA(updown, UDM_SETBASE, 80 , 0);
    expect(0,r);
    r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
    expect(16,r);

    /* Set base back to 10, return should be 16 */
    r = SendMessageA(updown, UDM_SETBASE, 10 , 0);
    expect(16,r);
    r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
    expect(10,r);

    ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_base_seq, "test updown base", FALSE);

    DestroyWindow(updown);

    /* switch base with buddy attached */
    updown = create_updown_control(UDS_SETBUDDYINT | UDS_ALIGNRIGHT, g_edit);

    r = SendMessageA(updown, UDM_SETPOS, 0, 10);
    expect(50, r);

    GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
    ok(lstrcmpA(text, "10") == 0, "Expected '10', got '%s'\n", text);

    r = SendMessageA(updown, UDM_SETBASE, 16, 0);
    expect(10, r);

    GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
    /* FIXME: currently hex output isn't properly formatted, but for this
       test only change from initial text matters */
    ok(lstrcmpA(text, "10") != 0, "Expected '0x000A', got '%s'\n", text);

    DestroyWindow(updown);
}
Ejemplo n.º 22
0
static void test_struct(void) {
    expect(14, sum((MyType){ 2, 3, 4, 5 }));
}
Ejemplo n.º 23
0
static void test_TBS_AUTOTICKS(void)
{
    HWND hWnd;
    int ret;

    hWnd = create_trackbar(TBS_AUTOTICKS, hWndParent);

    ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
    expect(2, ret);
    ret = SendMessage(hWnd, TBM_GETTIC, 0, 0);
    expect(-1, ret);
    ret = SendMessage(hWnd, TBM_GETTICPOS, 0, 0);
    expect(-1, ret);
    ret = SendMessage(hWnd, TBM_GETRANGEMIN, 0, 0);
    expect(0, ret);
    ret = SendMessage(hWnd, TBM_GETRANGEMAX, 0, 0);
    expect(100, ret);

    /* TBM_SETRANGEMAX rebuilds tics */
    ret = SendMessage(hWnd, TBM_SETRANGEMAX, TRUE, 200);
    expect(0, ret);
    ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
    expect(201, ret);

    /* TBM_SETRANGEMIN rebuilds tics */
    ret = SendMessage(hWnd, TBM_SETRANGEMAX, TRUE, 100);
    expect(0, ret);
    ret = SendMessage(hWnd, TBM_SETRANGEMIN, TRUE, 10);
    expect(0, ret);
    ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
    expect(91, ret);

    ret = SendMessage(hWnd, TBM_SETRANGEMIN, TRUE, 0);
    expect(0, ret);

    /* TBM_SETRANGE rebuilds tics */
    ret = SendMessage(hWnd, TBM_SETRANGE, TRUE, MAKELONG(10, 200));
    expect(0, ret);
    ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
    expect(191, ret);

    DestroyWindow(hWnd);
}