Beispiel #1
0
		protected override void GenerateTestMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
		{
			System.Diagnostics.Trace.Assert(this.Restrictions.Count > 0);

			StringBuilder ifCond = new StringBuilder();
			foreach (IRestriction restriction in this.Restrictions)
			{
				ifCond.Append(restriction.GetCheckCodeValid("*" + localValueVarName));
				ifCond.Append(" || ");

				localValueVarUsed = true;
			}

			ifCond.Length -= 4;

			IfThenElse ite = new IfThenElse(ifCond.ToString());
			ite.AddCode(String.Format("{0} = {1};", retErrVarName, LwipDefs.Def_ErrorCode_Ok));
			container.AddElement(ite);
		}
Beispiel #2
0
		public override void GenerateTestMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
		{
			if (this.Restrictions.Count > 0)
			{
				const string bitVarName = "bits";

				container.Declarations.Add(new VariableDeclaration(new VariableType(bitVarName, LwipDefs.Vt_U32)));

				IfThenElse ite = new IfThenElse(String.Format(
					"snmp_decode_bits(({0} *){1}, {2}, &{3}) == ERR_OK",
					LwipDefs.Vt_U8,
					valueVarName,
					lenVarName,
					bitVarName));

				valueVarUsed = true;
				lenVarUsed = true;

				StringBuilder innerIfCond = new StringBuilder();
				foreach (IRestriction restriction in this.Restrictions)
				{
					innerIfCond.Append(restriction.GetCheckCodeValid(bitVarName));
					innerIfCond.Append(" || ");
				}

				innerIfCond.Length -= 4;

				IfThenElse innerIte = new IfThenElse(innerIfCond.ToString());
				innerIte.AddCode(String.Format("{0} = {1};", retErrVarName, LwipDefs.Def_ErrorCode_Ok));
				ite.AddElement(innerIte);
				container.AddElement(ite);
			}
			else
			{
				base.GenerateTestMethodCode(container, valueVarName, ref valueVarUsed, lenVarName, ref lenVarUsed, retErrVarName);
			}
		}