Stun Server  Compliant with the latest RFCs including 5389, 5769, and 5780
discover the local host's own external IP address
testatomichelpers.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2013 John Selbie
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #include "commonincludes.hpp"
18 #include "testatomichelpers.h"
19 #include "atomichelpers.h"
20 
21 
23 {
24  HRESULT hr = S_OK;
25 
26  int value = -2000;
27  int nextexpected = -2000;
28  int result = 0;
29 
30  while (value < 2000)
31  {
32  nextexpected++;
33  result = AtomicIncrement(&value);
34  ChkIf(result != nextexpected, E_UNEXPECTED);
35  ChkIf(result != value, E_UNEXPECTED);
36  }
37 
38  value = 2000;
39  nextexpected = 2000;
40  while (value > -2000)
41  {
42  nextexpected--;
43  result = AtomicDecrement(&value);
44  ChkIf(result != nextexpected, E_UNEXPECTED);
45  ChkIf(result != value, E_UNEXPECTED);
46  }
47 
48 Cleanup:
49  return hr;
50 }
#define S_OK
Definition: hresult.h:46
virtual HRESULT Run()
int AtomicIncrement(int *pInt)
#define ChkIf(expr, hrerror)
Definition: chkmacros.h:63
#define E_UNEXPECTED
Definition: hresult.h:48
int32_t HRESULT
Definition: hresult.h:22
int AtomicDecrement(int *pInt)